Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

PyTorch's ParsedArgs::tensor() copies the returned tensor #6

Open
nunoplopes opened this issue Sep 9, 2021 · 0 comments
Open

PyTorch's ParsedArgs::tensor() copies the returned tensor #6

nunoplopes opened this issue Sep 9, 2021 · 0 comments

Comments

@nunoplopes
Copy link
Owner

e.g.: pytorch/torch/csrc/autograd/python_variable.cpp

static PyObject* THPVariable_make_subclass(PyObject* _ignored, PyObject* args, PyObject* kwargs) {
...
  auto data = r.tensor(1).detach();

That r.tensor(1) copies the tensor and then detaches. Unnecessary copy.

PythonArgs::optionalTensor should be changed to return a null/non-null ptr instead of optional

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

No branches or pull requests

1 participant