KEMBAR78
_unsafe_view returns copy if self has conjugate bit set · Issue #60478 · pytorch/pytorch · GitHub
Skip to content

_unsafe_view returns copy if self has conjugate bit set #60478

@soulitzer

Description

@soulitzer

Since _unsafe_view's schema has no alias info, ConjugateFallback considers it an out-of-place operation, so the conjugate is always materialized, producing a copy.

auto a = torch::tensor(1., at::TensorOptions().dtype(at::ScalarType::ComplexDouble)).conj();
auto b = at::_unsafe_view(a, {1});
b += 1;
std::cout << "a: " << a << "b: " << b << std::endl;

Output:

a: 
[W Copy.cpp:240] Warning: Casting complex values to real discards the imaginary part (function operator())
1
[ CPUComplexDoubleType{} ]
b: 
 2
[ CPUComplexDoubleType{1} ]

cc @ezyang @gchanan @zou3519 @bdhirsh @jbschlosser @anjali411 @dylanbespalko @mruberry @lezcano @nikitaved

Metadata

Metadata

Assignees

No one assigned

    Labels

    high prioritymodule: complexRelated to complex number support in PyTorchtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions