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

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

@nunoplopes

Description

@nunoplopes

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions