Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .as_cpu() to TensorCPU and TensorListCPU #5751

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jantonguirao
Copy link
Contributor

Category:

New feature

Description:

Adds a new API .as_cpu() to TensorCPU and TensorListCPU classes, similar to the one in TensorGPU and TensorListGPU.
This simplifies writing generic code that can take both CPU or GPU tensors.
For CPU, it is a bypass operation

Additional information:

Affected modules and functionalities:

TensorCPU and TensorListCPU

Key points relevant for the review:

Tests:

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: N/A

@jantonguirao
Copy link
Contributor Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21514315]: BUILD STARTED

@JanuszL JanuszL self-assigned this Dec 16, 2024
dali/python/backend_impl.cc Outdated Show resolved Hide resolved
@@ -1174,6 +1179,10 @@ void ExposeTensorList(py::module &m) {
Returns a `TensorListGPU` object being a copy of this `TensorListCPU`.
)code",
py::return_value_policy::take_ownership)
.def("as_cpu", [](TensorList<CPUBackend> &t) {
return t;
}, R"code(Bypass, as it is already an instance of `TensorListCPU`.)code",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}, R"code(Bypass, as it is already an instance of `TensorListCPU`.)code",
}, R"code(No-op, as it is already an instance of `TensorListCPU`.)code",

@szalpal szalpal self-assigned this Dec 16, 2024
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21514315]: BUILD FAILED

klecki
klecki previously requested changes Dec 16, 2024
Copy link
Contributor

@klecki klecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21515824]: BUILD STARTED

@jantonguirao
Copy link
Contributor Author

We need to adjust the .pyi file as well: #5153 https://github.com/NVIDIA/DALI/blob/main/dali/python/nvidia/dali/tensors.pyi

Done

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21515880]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21515880]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21518436]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21518436]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21574166]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21574166]: BUILD FAILED

@@ -1174,6 +1179,10 @@ void ExposeTensorList(py::module &m) {
Returns a `TensorListGPU` object being a copy of this `TensorListCPU`.
)code",
py::return_value_policy::take_ownership)
.def("as_cpu", [](TensorList<CPUBackend> &t) {
Copy link
Contributor

@mzient mzient Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.def("as_cpu", [](TensorList<CPUBackend> &t) {
.def("as_cpu", [](TensorList<CPUBackend> &t) -> TensorList<CPUBackend> & {

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21612243]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21612243]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21648900]: BUILD STARTED

@jantonguirao jantonguirao force-pushed the add_as_cpu_bypass branch 3 times, most recently from be087a6 to ce3b3f7 Compare December 19, 2024 07:58
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21650689]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21650844]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21678033]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21678984]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21678984]: BUILD FAILED

Signed-off-by: Joaquin Anton Guirao <[email protected]>
Signed-off-by: Joaquin Anton Guirao <[email protected]>
Signed-off-by: Joaquin Anton Guirao <[email protected]>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21783114]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21783114]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21815118]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21815175]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21819424]: BUILD STARTED

Signed-off-by: Joaquin Anton Guirao <[email protected]>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21823142]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21815175]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [21823142]: BUILD FAILED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants