Roger-luo/pytorch-complex

cannot fill complex number

Closed this issue · 1 comments

from torch_complex import torch
a = torch.empty(2, 2, dtype=torch.complex128)
a.fill_(1.j)

throws

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    a.fill_(1.j)
TypeError: fill_() received an invalid combination of arguments - got (complex), but expected one of:
 * (Tensor value)
      didn't match because some of the arguments have invalid types: (complex)
 * (Number value)
      didn't match because some of the arguments have invalid types: (complex)

trace

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x00007fff52cba1f6 libc++abi.dylib`__cxa_throw
    frame #1: 0x0000000110a3195f _C.cpython-36m-darwin.so`torch::PythonArgParser::print_error(this=0x0000000110c7b200, args=0x0000000101882048, kwargs=0x0000000000000000, parsed_args=0x00007ffeefbfef00) at python_arg_parser.cpp:568
    frame #2: 0x0000000110a30a68 _C.cpython-36m-darwin.so`torch::PythonArgParser::raw_parse(this=0x0000000110c7b200, args=0x0000000101882048, kwargs=0x0000000000000000, parsed_args=0x00007ffeefbfef00) at python_arg_parser.cpp:541
    frame #3: 0x00000001100136b7 _C.cpython-36m-darwin.so`torch::PythonArgs torch::PythonArgParser::parse<2>(this=0x0000000110c7b200, args=0x0000000101882048, kwargs=0x0000000000000000, dst=0x00007ffeefbfef00) at python_arg_parser.h:193
    frame #4: 0x000000011049b586 _C.cpython-36m-darwin.so`torch::autograd::THPVariable_fill_(self_=0x00000001018f4948, args=0x0000000101882048, kwargs=0x0000000000000000) at python_variable_methods.cpp:1976
    frame #5: 0x00000001000e513e .Python`_PyCFunction_FastCallDict + 463
    frame #6: 0x000000010014b0f6 .Python`call_function + 491
    frame #7: 0x0000000100143631 .Python`_PyEval_EvalFrameDefault + 1659
    frame #8: 0x000000010014b876 .Python`_PyEval_EvalCodeWithName + 1747
    frame #9: 0x0000000100142f3c .Python`PyEval_EvalCode + 42
    frame #10: 0x000000010016bacf .Python`run_mod + 54
    frame #11: 0x000000010016aade .Python`PyRun_FileExFlags + 164
    frame #12: 0x000000010016a1c9 .Python`PyRun_SimpleFileExFlags + 283
    frame #13: 0x000000010017efaa .Python`Py_Main + 3466
    frame #14: 0x0000000100001e1d python`___lldb_unnamed_symbol1$$python + 227
    frame #15: 0x00007fff54cf8015 libdyld.dylib`start + 1

Fixed