Skip to content

[Complex Autograd] pow_backward functions throw error for complex dtypes #41510

@anjali411

Description

@anjali411

Comparison ops are not implemented for complex tensors, so pow backward (which uses >= ) needs to be updated to work for complex tensors.

>>> import torch
>>> x=torch.randn(2, dtype=torch.cdouble, requires_grad=True)
>>> y=torch.randn(2, dtype=torch.cdouble, requires_grad=True)
>>> z=torch.pow(x, y)
>>> x
tensor([-1.0669+0.5799j,  0.8213-1.3650j], dtype=torch.complex128,
       requires_grad=True)
>>> torch.autograd.gradcheck(torch.pow, [x, y])
/data/users/chourdiaanjali/miniconda3/envs/myenv2/lib/python3.6/site-packages/torch/autograd/__init__.py:192: UserWarning: Complex backward is not fully supported yet and could lead to wrong gradients for functions we have not fixed yet (Triggered internally at  ../torch/csrc/autograd/python_engine.cpp:157.)
  inputs, allow_unused)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/users/chourdiaanjali/miniconda3/envs/myenv2/lib/python3.6/site-packages/torch/autograd/gradcheck.py", line 305, in gradcheck
    analytical, reentrant, correct_grad_sizes = get_analytical_jacobian(tupled_inputs, o, nondet_tol=nondet_tol)
  File "/data/users/chourdiaanjali/miniconda3/envs/myenv2/lib/python3.6/site-packages/torch/autograd/gradcheck.py", line 158, in get_analytical_jacobian
    retain_graph=True, allow_unused=True)
  File "/data/users/chourdiaanjali/miniconda3/envs/myenv2/lib/python3.6/site-packages/torch/autograd/__init__.py", line 192, in grad
    inputs, allow_unused)
RuntimeError: "ge_cpu" not implemented for 'ComplexDouble'

cc @ezyang @anjali411 @dylanbespalko @mruberry

Metadata

Metadata

Assignees

No one assigned

    Labels

    complex_autogradmodule: 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