Skip to content

Conjugate view tensor - #44799

Closed
ezyang wants to merge 10 commits into
gh/ezyang/839/basefrom
gh/ezyang/839/head
Closed

ezyang wants to merge 10 commits into
gh/ezyang/839/basefrom
gh/ezyang/839/head

Conversation

@ezyang

@ezyang ezyang commented Sep 16, 2020 •

Copy link
Copy Markdown
Contributor

Stack from ghstack:

Based off of bdhirsch's prototype at #43702

Conjugate view tensor changes the semantics of x.conj() to return a view
of the original tensor, rather than immediately performing the
conjugation (aka, it implements a form of lazy evaluation for
conjugation). This permits conjugations to be fused with later
operations that occur; e.g., matrix multiply, where BLAS libraries
typically all for a conjugate-transpose first argument.

The implementation strategy of this PR:

  • Maintain conjugation status as a dispatch key in the dispatch
    key set (TODO: audit all propagation of key_set to ensure that
    we don't propagate conjugation status when we shouldn't)

  • Implement a few new functions for some other operations:

    • x.is_conj() tells you whether or not the conjugate bit is
      or not. If not x.is_conj(), what's in memory reflects
      the semantic content of the tensor; if x.is_conj(),
      the imaginary values are negated. This is implemented
      as a fastpath function similar to numel(); see
      Natively Declarable Fast-path Functions  #30774

    • x.view_as_real_physical() lets you view the underlying memory
      of a possibly conjugated tensor as its actual stored
      representation. To interpret this result correctly, you
      will typically also have to query x.is_conj()

    • x.conj_physical_() will inplace flip the sign of the
      imaginary piece of the tensor. This is a fairly useful
      operation, especially when getting conjugations to line
      up correctly. TODO: Consider renaming this to just conj_()

    • x.resolve_conj() plays of contiguous() but for conjugate views:
      if x.is_conj(), it will return a new tensor with the conjugation
      done in memory.

  • Disable view_as_real() for conjugated tensors. This change is
    necessary because conjugation is a concept only for complex
    tensors; on real tensors, there is no way to say "view this
    memory but negate every Nth element". Most notably, this
    means x.imag no longer works on conjugated tensors; instead
    you should do x.resolve_conj().imag instead.

  • Implement a backend fallback on the conjugate dispatch key.
    This fallback works for all non-view operations. The general
    recipe is to take each tensor argument that is_conj() and
    resolve_conj() them. If an argument is a mutable inplace argument,
    we instead conj_physical_() inplace, set_conj(False) and then
    do our operation; on the way out, we then invert this operation.

TODO: User-level docs

Signed-off-by: Edward Z. Yang [email protected]

Based off of bdhirsch's prototype at #43702

[ghstack-poisoned]
@ezyang ezyang mentioned this pull request Sep 16, 2020
ezyang added a commit that referenced this pull request Sep 16, 2020
Based off of bdhirsch's prototype at #43702

ghstack-source-id: dcd8f07
Pull Request resolved: #44799
@anjali411 anjali411 added the module: complex Related to complex number support in PyTorch label Sep 16, 2020
@dr-ci

dr-ci Bot commented Sep 16, 2020 •

Copy link
Copy Markdown

💊 CI failures summary and remediations

As of commit 0c67830 (more details on the Dr. CI page):


  • 31/31 failures possibly* introduced in this PR
    • 1/31 non-scanned failure(s)

🕵️ 30 new failures recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See CircleCI build pytorch_ios_12_0_0_x86_64_build (1/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:34:06 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:34:06   File "/Users/distiller/anaconda/lib/python3.8/runpy.py", line 87, in _run_code
Mar 29 15:34:06     exec(code, run_globals)
Mar 29 15:34:06   File "/Users/distiller/project/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:34:06     main()
Mar 29 15:34:06   File "/Users/distiller/project/tools/codegen/gen.py", line 803, in main
Mar 29 15:34:06     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:34:06   File "/Users/distiller/project/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:34:06     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:34:06   File "/Users/distiller/project/tools/codegen/model.py", line 275, in from_yaml
Mar 29 15:34:06     assert use_c10_dispatcher_s != 'full', \
Mar 29 15:34:06 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:34:06   in /Users/distiller/project/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:34:06     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:34:06 -- 
Mar 29 15:34:06 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:34:06   Failed to get generated_cpp list
Mar 29 15:34:06 Call Stack (most recent call first):
Mar 29 15:34:06   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:34:06 
Mar 29 15:34:06 
Mar 29 15:34:06 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_linux_xenial_py3_clang5_asan_build (2/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:36:24 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:36:24   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:36:24     exec(code, run_globals)
Mar 29 15:36:24   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:36:24     main()
Mar 29 15:36:24   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:36:24     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:36:24   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:36:24     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:36:24   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:36:24     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:36:24 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:36:24   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:36:24     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:36:24 -- 
Mar 29 15:36:24 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:36:24   Failed to get generated_cpp list
Mar 29 15:36:24 Call Stack (most recent call first):
Mar 29 15:36:24   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:36:24 
Mar 29 15:36:24 
Mar 29 15:36:24 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_linux_xenial_py3_clang5_android_ndk_r19c_x86_32_build (3/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:37:23 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:37:23   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:37:23     exec(code, run_globals)
Mar 29 15:37:23   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:37:23     main()
Mar 29 15:37:23   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:37:23     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:37:23   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:37:23     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:37:23   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:37:23     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:37:23 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:37:23   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:37:23     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:37:23 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:37:23   Failed to get generated_cpp list
Mar 29 15:37:23 Call Stack (most recent call first):
Mar 29 15:37:23   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:37:23 
Mar 29 15:37:23 
Mar 29 15:37:23 -- 
Mar 29 15:37:23 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_windows_vs2019_py36_cpu_build (4/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  File "C:\Jenkins\Miniconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\circleci\project\tools\codegen\gen.py", line 989, in <module>
    main()
  File "C:\Users\circleci\project\tools\codegen\gen.py", line 803, in main
    native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
  File "C:\Users\circleci\project\tools\codegen\gen.py", line 80, in parse_native_yaml
    rs.append(NativeFunction.from_yaml(e, loc))
  File "C:\Users\circleci\project\tools\codegen\model.py", line 276, in from_yaml
    "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  in C:/Users/circleci/project/cmake/../aten/src/ATen\native/native_functions.yaml:298:
    view_as_real_physical(Tensor(a) self) -> Tensor(a)
-- 
CMake Error at cmake/Codegen.cmake:213 (message):
  Failed to get generated_cpp list
Call Stack (most recent call first):
  caffe2/CMakeLists.txt:2 (include)


-- Configuring incomplete, errors occurred!

See CircleCI build pytorch_linux_bionic_py3_8_gcc9_coverage_build (5/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:36:11 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:36:11   File "/opt/conda/lib/python3.8/runpy.py", line 87, in _run_code
Mar 29 15:36:11     exec(code, run_globals)
Mar 29 15:36:11   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:36:11     main()
Mar 29 15:36:11   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:36:11     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:36:11   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:36:11     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:36:11   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 275, in from_yaml
Mar 29 15:36:11     assert use_c10_dispatcher_s != 'full', \
Mar 29 15:36:11 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:36:11   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:36:11     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:36:11 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:36:11   Failed to get generated_cpp list
Mar 29 15:36:11 Call Stack (most recent call first):
Mar 29 15:36:11   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:36:11 
Mar 29 15:36:11 
Mar 29 15:36:11 -- 
Mar 29 15:36:11 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_linux_xenial_py3_clang5_mobile_build (6/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:36:06 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:36:06   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:36:06     exec(code, run_globals)
Mar 29 15:36:06   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:36:06     main()
Mar 29 15:36:06   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:36:06     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:36:06   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:36:06     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:36:06   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:36:06     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:36:06 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:36:06   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:36:06     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:36:06 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:36:06   Failed to get generated_cpp list
Mar 29 15:36:06 Call Stack (most recent call first):
Mar 29 15:36:06   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:36:06 
Mar 29 15:36:06 
Mar 29 15:36:06 -- 
Mar 29 15:36:06 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_linux_bionic_py3_6_clang9_noarch_build (7/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:38:18 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:38:18   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:38:18     exec(code, run_globals)
Mar 29 15:38:18   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:38:18     main()
Mar 29 15:38:18   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:38:18     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:38:18   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:38:18     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:38:18   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:38:18     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:38:18 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:38:18   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:38:18     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:38:18 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:38:18   Failed to get generated_cpp list
Mar 29 15:38:18 Call Stack (most recent call first):
Mar 29 15:38:18   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:38:18 
Mar 29 15:38:18 
Mar 29 15:38:18 -- 
Mar 29 15:38:18 -- Configuring incomplete, errors occurred!

See CircleCI build binary_linux_libtorch_3_7m_cpu_devtoolset7_shared-with-deps_build (8/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  File "/opt/python/cp37-cp37m/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/pytorch/tools/codegen/gen.py", line 989, in <module>
    main()
  File "/pytorch/tools/codegen/gen.py", line 803, in main
    native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
  File "/pytorch/tools/codegen/gen.py", line 80, in parse_native_yaml
    rs.append(NativeFunction.from_yaml(e, loc))
  File "/pytorch/tools/codegen/model.py", line 276, in from_yaml
    "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  in /pytorch/cmake/../aten/src/ATen/native/native_functions.yaml:298:
    view_as_real_physical(Tensor(a) self) -> Tensor(a)
-- 
CMake Error at cmake/Codegen.cmake:213 (message):
  Failed to get generated_cpp list
Call Stack (most recent call first):
  caffe2/CMakeLists.txt:2 (include)


-- Configuring incomplete, errors occurred!

See CircleCI build pytorch_linux_bionic_rocm3_9_py3_6_build (9/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:39:08 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:39:08   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:39:08     exec(code, run_globals)
Mar 29 15:39:08   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:39:08     main()
Mar 29 15:39:08   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:39:08     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:39:08   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:39:08     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:39:08   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:39:08     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:39:08 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:39:08   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:39:08     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:39:08 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:39:08   Failed to get generated_cpp list
Mar 29 15:39:08 Call Stack (most recent call first):
Mar 29 15:39:08   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:39:08 
Mar 29 15:39:08 
Mar 29 15:39:08 -- 
Mar 29 15:39:08 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_ios_12_0_0_x86_64_lite_interpreter_build (10/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:35:53 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:35:53   File "/Users/distiller/anaconda/lib/python3.8/runpy.py", line 87, in _run_code
Mar 29 15:35:53     exec(code, run_globals)
Mar 29 15:35:53   File "/Users/distiller/project/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:35:53     main()
Mar 29 15:35:53   File "/Users/distiller/project/tools/codegen/gen.py", line 803, in main
Mar 29 15:35:53     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:35:53   File "/Users/distiller/project/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:35:53     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:35:53   File "/Users/distiller/project/tools/codegen/model.py", line 275, in from_yaml
Mar 29 15:35:53     assert use_c10_dispatcher_s != 'full', \
Mar 29 15:35:53 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:35:53   in /Users/distiller/project/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:35:53     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:35:53 -- 
Mar 29 15:35:53 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:35:53   Failed to get generated_cpp list
Mar 29 15:35:53 Call Stack (most recent call first):
Mar 29 15:35:53   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:35:53 
Mar 29 15:35:53 
Mar 29 15:35:53 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_windows_vs2019_py36_cuda10.1_build (11/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  File "C:\Jenkins\Miniconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\circleci\project\tools\codegen\gen.py", line 989, in <module>
    main()
  File "C:\Users\circleci\project\tools\codegen\gen.py", line 803, in main
    native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
  File "C:\Users\circleci\project\tools\codegen\gen.py", line 80, in parse_native_yaml
    rs.append(NativeFunction.from_yaml(e, loc))
  File "C:\Users\circleci\project\tools\codegen\model.py", line 276, in from_yaml
    "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  in C:/Users/circleci/project/cmake/../aten/src/ATen\native/native_functions.yaml:298:
    view_as_real_physical(Tensor(a) self) -> Tensor(a)
-- 
CMake Error at cmake/Codegen.cmake:213 (message):
  Failed to get generated_cpp list
Call Stack (most recent call first):
  caffe2/CMakeLists.txt:2 (include)


-- Configuring incomplete, errors occurred!

See CircleCI build binary_windows_libtorch_3_7_cpu_release_build (12/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  File "C:\w\b\windows\conda\envs\py37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\w\b\windows\pytorch\tools\codegen\gen.py", line 989, in <module>
    main()
  File "C:\w\b\windows\pytorch\tools\codegen\gen.py", line 803, in main
    native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
  File "C:\w\b\windows\pytorch\tools\codegen\gen.py", line 80, in parse_native_yaml
    rs.append(NativeFunction.from_yaml(e, loc))
  File "C:\w\b\windows\pytorch\tools\codegen\model.py", line 276, in from_yaml
    "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  in C:/w/b/windows/pytorch/cmake/../aten/src/ATen\native/native_functions.yaml:298:
    view_as_real_physical(Tensor(a) self) -> Tensor(a)
-- 
CMake Error at cmake/Codegen.cmake:213 (message):
  Failed to get generated_cpp list
Call Stack (most recent call first):
  caffe2/CMakeLists.txt:2 (include)


-- Configuring incomplete, errors occurred!

See CircleCI build pytorch_linux_xenial_py3_clang7_onnx_build (13/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:35:17 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:35:17   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:35:17     exec(code, run_globals)
Mar 29 15:35:17   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:35:17     main()
Mar 29 15:35:17   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:35:17     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:35:17   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:35:17     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:35:17   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:35:17     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:35:17 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:35:17   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:35:17     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:35:17 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:35:17   Failed to get generated_cpp list
Mar 29 15:35:17 Call Stack (most recent call first):
Mar 29 15:35:17   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:35:17 
Mar 29 15:35:17 
Mar 29 15:35:17 -- 
Mar 29 15:35:17 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_linux_xenial_py3_clang5_mobile_custom_build_dynamic (14/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:37:51 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:37:51   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:37:51     exec(code, run_globals)
Mar 29 15:37:51   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:37:51     main()
Mar 29 15:37:51   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:37:51     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:37:51   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:37:51     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:37:51   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:37:51     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:37:51 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:37:51   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:37:51     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:37:51 -- 
Mar 29 15:37:51 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:37:51   Failed to get generated_cpp list
Mar 29 15:37:51 Call Stack (most recent call first):
Mar 29 15:37:51   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:37:51 
Mar 29 15:37:51 
Mar 29 15:37:51 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_macos_10_13_py3_build (15/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:34:16 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:34:16   File "/Users/distiller/workspace/miniconda3/lib/python3.7/runpy.py", line 85, in _run_code
Mar 29 15:34:16     exec(code, run_globals)
Mar 29 15:34:16   File "/Users/distiller/project/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:34:16     main()
Mar 29 15:34:16   File "/Users/distiller/project/tools/codegen/gen.py", line 803, in main
Mar 29 15:34:16     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:34:16   File "/Users/distiller/project/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:34:16     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:34:16   File "/Users/distiller/project/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:34:16     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:34:16 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:34:16   in /Users/distiller/project/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:34:16     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:34:16 -- 
Mar 29 15:34:16 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:34:16   Failed to get generated_cpp list
Mar 29 15:34:16 Call Stack (most recent call first):
Mar 29 15:34:16   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:34:16 
Mar 29 15:34:16 
Mar 29 15:34:16 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_linux_xenial_py3_clang5_mobile_custom_build_static (16/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:37:37 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:37:37   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:37:37     exec(code, run_globals)
Mar 29 15:37:37   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:37:37     main()
Mar 29 15:37:37   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:37:37     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:37:37   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:37:37     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:37:37   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:37:37     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:37:37 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:37:37   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:37:37     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:37:37 -- 
Mar 29 15:37:37 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:37:37   Failed to get generated_cpp list
Mar 29 15:37:37 Call Stack (most recent call first):
Mar 29 15:37:37   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:37:37 
Mar 29 15:37:37 
Mar 29 15:37:37 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_libtorch_linux_xenial_cuda11_1_cudnn8_py3_gcc7_build (17/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:40:01 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:40:01   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:40:01     exec(code, run_globals)
Mar 29 15:40:01   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:40:01     main()
Mar 29 15:40:01   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:40:01     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:40:01   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:40:01     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:40:01   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:40:01     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:40:01 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:40:01   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:40:01     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:40:01 -- 
Mar 29 15:40:01 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:40:01   Failed to get generated_cpp list
Mar 29 15:40:01 Call Stack (most recent call first):
Mar 29 15:40:01   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:40:01 
Mar 29 15:40:01 
Mar 29 15:40:01 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single (18/30)

Step: "pytorch android gradle custom build single architecture (for PR)" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:38:33 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:38:33   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:38:33     exec(code, run_globals)
Mar 29 15:38:33   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:38:33     main()
Mar 29 15:38:33   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:38:33     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:38:33   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:38:33     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:38:33   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:38:33     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:38:33 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:38:33   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:38:33     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:38:33 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:38:33   Failed to get generated_cpp list
Mar 29 15:38:33 Call Stack (most recent call first):
Mar 29 15:38:33   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:38:33 
Mar 29 15:38:33 
Mar 29 15:38:33 -- 
Mar 29 15:38:33 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_bazel_build (19/30)

Step: "Bazel Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:36:23 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:36:23 Use --sandbox_debug to see verbose messages from the sandbox
Mar 29 15:36:23 Traceback (most recent call last):
Mar 29 15:36:23   File "/var/lib/jenkins/.cache/bazel/_bazel_jenkins/fdf6d09bf4b4f04a71e2a7dfceb40620/sandbox/processwrapper-sandbox/192/execroot/pytorch/bazel-out/host/bin/gen.runfiles/pytorch/tools/setup_helpers/gen.py", line 11, in <module>
Mar 29 15:36:23     tools.codegen.gen.main()
Mar 29 15:36:23   File "/var/lib/jenkins/.cache/bazel/_bazel_jenkins/fdf6d09bf4b4f04a71e2a7dfceb40620/sandbox/processwrapper-sandbox/192/execroot/pytorch/bazel-out/host/bin/gen.runfiles/pytorch/tools/codegen/gen.py", line 803, in main
Mar 29 15:36:23     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:36:23   File "/var/lib/jenkins/.cache/bazel/_bazel_jenkins/fdf6d09bf4b4f04a71e2a7dfceb40620/sandbox/processwrapper-sandbox/192/execroot/pytorch/bazel-out/host/bin/gen.runfiles/pytorch/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:36:23     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:36:23   File "/var/lib/jenkins/.cache/bazel/_bazel_jenkins/fdf6d09bf4b4f04a71e2a7dfceb40620/sandbox/processwrapper-sandbox/192/execroot/pytorch/bazel-out/host/bin/gen.runfiles/pytorch/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:36:23     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:36:23 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:36:23   in aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:36:23     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:36:23 ----------------
Mar 29 15:36:23 Note: The failure of target //:gen (with exit code 1) may have been caused by the fact that it is running under Python 3 instead of Python 2. Examine the error to determine if that appears to be the problem. Since this target is built in the host configuration, the only way to change its version is to set --host_force_python=PY2, which affects the entire build.
Mar 29 15:36:23 
Mar 29 15:36:23 If this error started occurring in Bazel 0.27 and later, it may be because the Python toolchain now enforces that targets analyzed as PY2 and PY3 run under a Python 2 and Python 3 interpreter, respectively. See https://github.com/bazelbuild/bazel/issues/7899 for more information.
Mar 29 15:36:23 ----------------
Mar 29 15:36:23 Target //:torch failed to build
Mar 29 15:36:23 Use --verbose_failures to see the command lines of failed build steps.
Mar 29 15:36:23 ERROR: /var/lib/jenkins/workspace/BUILD.bazel:645:1 Executing genrule //:generated_cpp failed (Exit 1) bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped)

See CircleCI build pytorch_linux_xenial_cuda10_2_cudnn7_py3_gcc7_build (20/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:37:39 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:37:39   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:37:39     exec(code, run_globals)
Mar 29 15:37:39   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:37:39     main()
Mar 29 15:37:39   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:37:39     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:37:39   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:37:39     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:37:39   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:37:39     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:37:39 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:37:39   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:37:39     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:37:39 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:37:39   Failed to get generated_cpp list
Mar 29 15:37:39 Call Stack (most recent call first):
Mar 29 15:37:39   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:37:39 
Mar 29 15:37:39 
Mar 29 15:37:39 -- 
Mar 29 15:37:39 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_macos_10_15_py3_build (21/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:37:31 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:37:31   File "/Users/distiller/workspace/miniconda3/lib/python3.8/runpy.py", line 87, in _run_code
Mar 29 15:37:31     exec(code, run_globals)
Mar 29 15:37:31   File "/Users/distiller/project/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:37:31     main()
Mar 29 15:37:31   File "/Users/distiller/project/tools/codegen/gen.py", line 803, in main
Mar 29 15:37:31     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:37:31   File "/Users/distiller/project/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:37:31     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:37:31   File "/Users/distiller/project/tools/codegen/model.py", line 275, in from_yaml
Mar 29 15:37:31     assert use_c10_dispatcher_s != 'full', \
Mar 29 15:37:31 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:37:31   in /Users/distiller/project/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:37:31     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:37:31 -- 
Mar 29 15:37:31 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:37:31   Failed to get generated_cpp list
Mar 29 15:37:31 Call Stack (most recent call first):
Mar 29 15:37:31   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:37:31 
Mar 29 15:37:31 
Mar 29 15:37:31 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_vulkan_linux_bionic_py3_6_clang9_build (22/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:37:52 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:37:52   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:37:52     exec(code, run_globals)
Mar 29 15:37:52   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:37:52     main()
Mar 29 15:37:52   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:37:52     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:37:52   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:37:52     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:37:52   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:37:52     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:37:52 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:37:52   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:37:52     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:37:52 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:37:52   Failed to get generated_cpp list
Mar 29 15:37:52 Call Stack (most recent call first):
Mar 29 15:37:52   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:37:52 
Mar 29 15:37:52 
Mar 29 15:37:52 -- 
Mar 29 15:37:52 -- Configuring incomplete, errors occurred!

See CircleCI build pytorch_xla_linux_bionic_py3_6_clang9_build (23/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:39:03 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:39:03   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:39:03     exec(code, run_globals)
Mar 29 15:39:03   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:39:03     main()
Mar 29 15:39:03   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:39:03     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:39:03   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:39:03     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:39:03   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:39:03     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:39:03 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:39:03   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:39:03     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:39:03 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:39:03   Failed to get generated_cpp list
Mar 29 15:39:03 Call Stack (most recent call first):
Mar 29 15:39:03   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:39:03 
Mar 29 15:39:03 
Mar 29 15:39:03 -- 
Mar 29 15:39:03 -- Configuring incomplete, errors occurred!

See CircleCI build binary_linux_libtorch_3_7m_cpu_gcc5_4_cxx11-abi_shared-with-deps_build (24/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  File "/opt/conda/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/pytorch/tools/codegen/gen.py", line 989, in <module>
    main()
  File "/pytorch/tools/codegen/gen.py", line 803, in main
    native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
  File "/pytorch/tools/codegen/gen.py", line 80, in parse_native_yaml
    rs.append(NativeFunction.from_yaml(e, loc))
  File "/pytorch/tools/codegen/model.py", line 275, in from_yaml
    assert use_c10_dispatcher_s != 'full', \
AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  in /pytorch/cmake/../aten/src/ATen/native/native_functions.yaml:298:
    view_as_real_physical(Tensor(a) self) -> Tensor(a)
-- 
CMake Error at cmake/Codegen.cmake:213 (message):
  Failed to get generated_cpp list
Call Stack (most recent call first):
  caffe2/CMakeLists.txt:2 (include)


-- Configuring incomplete, errors occurred!

See CircleCI build pytorch_windows_vs2019_py36_cuda11.1_build (25/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  File "C:\Jenkins\Miniconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\circleci\project\tools\codegen\gen.py", line 989, in <module>
    main()
  File "C:\Users\circleci\project\tools\codegen\gen.py", line 803, in main
    native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
  File "C:\Users\circleci\project\tools\codegen\gen.py", line 80, in parse_native_yaml
    rs.append(NativeFunction.from_yaml(e, loc))
  File "C:\Users\circleci\project\tools\codegen\model.py", line 276, in from_yaml
    "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  in C:/Users/circleci/project/cmake/../aten/src/ATen\native/native_functions.yaml:298:
    view_as_real_physical(Tensor(a) self) -> Tensor(a)
-- 
CMake Error at cmake/Codegen.cmake:213 (message):
  Failed to get generated_cpp list
Call Stack (most recent call first):
  caffe2/CMakeLists.txt:2 (include)


-- Configuring incomplete, errors occurred!

See CircleCI build pytorch_linux_xenial_py3_6_gcc5_4_build (26/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Mar 29 15:36:16 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:36:16   File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
Mar 29 15:36:16     exec(code, run_globals)
Mar 29 15:36:16   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 989, in <module>
Mar 29 15:36:16     main()
Mar 29 15:36:16   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 803, in main
Mar 29 15:36:16     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
Mar 29 15:36:16   File "/var/lib/jenkins/workspace/tools/codegen/gen.py", line 80, in parse_native_yaml
Mar 29 15:36:16     rs.append(NativeFunction.from_yaml(e, loc))
Mar 29 15:36:16   File "/var/lib/jenkins/workspace/tools/codegen/model.py", line 276, in from_yaml
Mar 29 15:36:16     "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
Mar 29 15:36:16 AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
Mar 29 15:36:16   in /var/lib/jenkins/workspace/cmake/../aten/src/ATen/native/native_functions.yaml:298:
Mar 29 15:36:16     view_as_real_physical(Tensor(a) self) -> Tensor(a)
Mar 29 15:36:16 CMake Error at cmake/Codegen.cmake:213 (message):
Mar 29 15:36:16   Failed to get generated_cpp list
Mar 29 15:36:16 Call Stack (most recent call first):
Mar 29 15:36:16   caffe2/CMakeLists.txt:2 (include)
Mar 29 15:36:16 
Mar 29 15:36:16 
Mar 29 15:36:16 -- 
Mar 29 15:36:16 -- Configuring incomplete, errors occurred!

See CircleCI build binary_windows_libtorch_3_7_cpu_debug_build (27/30)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  File "C:\w\b\windows\conda\envs\py37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\w\b\windows\pytorch\tools\codegen\gen.py", line 989, in <module>
    main()
  File "C:\w\b\windows\pytorch\tools\codegen\gen.py", line 803, in main
    native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
  File "C:\w\b\windows\pytorch\tools\codegen\gen.py", line 80, in parse_native_yaml
    rs.append(NativeFunction.from_yaml(e, loc))
  File "C:\w\b\windows\pytorch\tools\codegen\model.py", line 276, in from_yaml
    "There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line."
AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
  in C:/w/b/windows/pytorch/cmake/../aten/src/ATen\native/native_functions.yaml:298:
    view_as_real_physical(Tensor(a) self) -> Tensor(a)
-- 
CMake Error at cmake/Codegen.cmake:213 (message):
  Failed to get generated_cpp list
Call Stack (most recent call first):
  caffe2/CMakeLists.txt:2 (include)


-- Configuring incomplete, errors occurred!

See GitHub Actions build clang-tidy (28/30)

Step: "Run clang-tidy" (full log | diagnosis details | 🔁 rerun)

2021-03-29T15:35:36.4016597Z AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
2021-03-29T15:35:36.3995522Z   File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/runpy.py", line 87, in _run_code
2021-03-29T15:35:36.3997402Z     exec(code, run_globals)
2021-03-29T15:35:36.3998973Z   File "/home/runner/work/pytorch/pytorch/tools/codegen/gen.py", line 989, in <module>
2021-03-29T15:35:36.4002733Z     main()
2021-03-29T15:35:36.4004257Z   File "/home/runner/work/pytorch/pytorch/tools/codegen/gen.py", line 803, in main
2021-03-29T15:35:36.4007097Z     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
2021-03-29T15:35:36.4009408Z   File "/home/runner/work/pytorch/pytorch/tools/codegen/gen.py", line 80, in parse_native_yaml
2021-03-29T15:35:36.4011013Z     rs.append(NativeFunction.from_yaml(e, loc))
2021-03-29T15:35:36.4012802Z   File "/home/runner/work/pytorch/pytorch/tools/codegen/model.py", line 275, in from_yaml
2021-03-29T15:35:36.4014500Z     assert use_c10_dispatcher_s != 'full', \
2021-03-29T15:35:36.4016597Z AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
2021-03-29T15:35:36.4018654Z   in /home/runner/work/pytorch/pytorch/cmake/../aten/src/ATen/native/native_functions.yaml:298:
2021-03-29T15:35:36.4020446Z     view_as_real_physical(Tensor(a) self) -> Tensor(a)
2021-03-29T15:35:36.4161697Z CMake Error at cmake/Codegen.cmake:213 (message):
2021-03-29T15:35:36.4162846Z -- 
2021-03-29T15:35:36.4163847Z   Failed to get generated_cpp list
2021-03-29T15:35:36.4164544Z Call Stack (most recent call first):
2021-03-29T15:35:36.4165281Z   caffe2/CMakeLists.txt:2 (include)
2021-03-29T15:35:36.4165795Z 
2021-03-29T15:35:36.4166130Z 
2021-03-29T15:35:36.4209612Z -- Configuring incomplete, errors occurred!

See GitHub Actions build quick-checks (29/30)

Step: "C++ docs check" (full log | diagnosis details | 🔁 rerun)

2021-03-29T15:28:33.6854988Z AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
2021-03-29T15:28:33.6844357Z   File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/runpy.py", line 87, in _run_code
2021-03-29T15:28:33.6845225Z     exec(code, run_globals)
2021-03-29T15:28:33.6846156Z   File "/home/runner/work/pytorch/pytorch/tools/codegen/gen.py", line 989, in <module>
2021-03-29T15:28:33.6846861Z     main()
2021-03-29T15:28:33.6847573Z   File "/home/runner/work/pytorch/pytorch/tools/codegen/gen.py", line 803, in main
2021-03-29T15:28:33.6849452Z     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
2021-03-29T15:28:33.6850707Z   File "/home/runner/work/pytorch/pytorch/tools/codegen/gen.py", line 80, in parse_native_yaml
2021-03-29T15:28:33.6851654Z     rs.append(NativeFunction.from_yaml(e, loc))
2021-03-29T15:28:33.6852576Z   File "/home/runner/work/pytorch/pytorch/tools/codegen/model.py", line 275, in from_yaml
2021-03-29T15:28:33.6853698Z     assert use_c10_dispatcher_s != 'full', \
2021-03-29T15:28:33.6854988Z AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
2021-03-29T15:28:33.6856071Z   in aten/src/ATen/native/native_functions.yaml:298:
2021-03-29T15:28:33.6857136Z     view_as_real_physical(Tensor(a) self) -> Tensor(a)
2021-03-29T15:28:33.6974339Z ##[error]Process completed with exit code 1.
2021-03-29T15:28:33.7082521Z Post job cleanup.
2021-03-29T15:28:33.8172235Z [command]/usr/bin/git version
2021-03-29T15:28:33.8231635Z git version 2.31.0
2021-03-29T15:28:33.8272550Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2021-03-29T15:28:33.8308480Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2021-03-29T15:28:33.8641378Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2021-03-29T15:28:33.8692986Z http.https://github.com/.extraheader

See GitHub Actions build mypy (30/30)

Step: "Run autogen" (full log | diagnosis details | 🔁 rerun)

2021-03-29T15:28:15.6887560Z AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
2021-03-29T15:28:15.6872044Z   File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/runpy.py", line 87, in _run_code
2021-03-29T15:28:15.6873355Z     exec(code, run_globals)
2021-03-29T15:28:15.6874969Z   File "/home/runner/work/pytorch/pytorch/tools/codegen/gen.py", line 989, in <module>
2021-03-29T15:28:15.6876080Z     main()
2021-03-29T15:28:15.6877206Z   File "/home/runner/work/pytorch/pytorch/tools/codegen/gen.py", line 803, in main
2021-03-29T15:28:15.6879988Z     native_functions = parse_native_yaml(os.path.join(options.source_path, 'native/native_functions.yaml'))
2021-03-29T15:28:15.6882026Z   File "/home/runner/work/pytorch/pytorch/tools/codegen/gen.py", line 80, in parse_native_yaml
2021-03-29T15:28:15.6883576Z     rs.append(NativeFunction.from_yaml(e, loc))
2021-03-29T15:28:15.6885138Z   File "/home/runner/work/pytorch/pytorch/tools/codegen/model.py", line 275, in from_yaml
2021-03-29T15:28:15.6886401Z     assert use_c10_dispatcher_s != 'full', \
2021-03-29T15:28:15.6887560Z AssertionError: There is no need to specify 'use_c10_dispatcher: full' anymore. This is the default now. Just remove the line.
2021-03-29T15:28:15.6888548Z   in aten/src/ATen/native/native_functions.yaml:298:
2021-03-29T15:28:15.6889703Z     view_as_real_physical(Tensor(a) self) -> Tensor(a)
2021-03-29T15:28:15.6975509Z 
2021-03-29T15:28:15.6975821Z real	0m0.261s
2021-03-29T15:28:15.6976134Z user	0m0.228s
2021-03-29T15:28:15.6976423Z sys	0m0.024s
2021-03-29T15:28:15.6981296Z ##[error]Process completed with exit code 1.
2021-03-29T15:28:15.7082316Z Post job cleanup.
2021-03-29T15:28:15.8137901Z [command]/usr/bin/git version
2021-03-29T15:28:15.8215329Z git version 2.31.0

ci.pytorch.org: 1 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Based off of bdhirsch's prototype at #43702

Conjugate view tensor changes the semantics of x.conj() to return a view
of the original tensor, rather than immediately performing the
conjugation (aka, it implements a form of lazy evaluation for
conjugation).  This permits conjugations to be fused with later
operations that occur; e.g., matrix multiply, where BLAS libraries
typically all for a conjugate-transpose first argument.

The implementation strategy of this PR:

- Maintain conjugation status as a dispatch key in the dispatch
  key set (TODO: audit all propagation of key_set to ensure that
  we don't propagate conjugation status when we shouldn't)

- Implement a few new functions for some other operations:

  - x.is_conj() tells you whether or not the conjugate bit is
    or not.  If not x.is_conj(), what's in memory reflects
    the semantic content of the tensor; if x.is_conj(),
    the imaginary values are negated.  This is implemented
    as a fastpath function similar to numel(); see
    #30774

  - x.view_as_real_physical() lets you view the underlying memory
    of a possibly conjugated tensor as its actual stored
    representation.  To interpret this result correctly, you
    will typically also have to query x.is_conj()

  - x.conj_physical_() will inplace flip the sign of the
    imaginary piece of the tensor.  This is a fairly useful
    operation, especially when getting conjugations to line
    up correctly. TODO: Consider renaming this to just conj_()

  - x.resolve_conj() plays of contiguous() but for conjugate views:
    if x.is_conj(), it will return a new tensor with the conjugation
    done in memory.

- Disable view_as_real() for conjugated tensors.  This change is
  necessary because conjugation is a concept only for complex
  tensors; on real tensors, there is no way to say "view this
  memory but negate every Nth element".  Most notably, this
  means x.imag no longer works on conjugated tensors; instead
  you should do x.resolve_conj().imag instead.

- Implement a backend fallback on the conjugate dispatch key.
  This fallback works for all non-view operations.  The general
  recipe is to take each tensor argument that is_conj() and
  resolve_conj() them.  If an argument is a mutable inplace argument,
  we instead conj_physical_() inplace, set_conj(False) and then
  do our operation; on the way out, we then invert this operation.

TODO: User-level docs

Signed-off-by: Edward Z. Yang <[email protected]>

[ghstack-poisoned]
Based off of bdhirsch's prototype at #43702

Conjugate view tensor changes the semantics of x.conj() to return a view
of the original tensor, rather than immediately performing the
conjugation (aka, it implements a form of lazy evaluation for
conjugation).  This permits conjugations to be fused with later
operations that occur; e.g., matrix multiply, where BLAS libraries
typically all for a conjugate-transpose first argument.

The implementation strategy of this PR:

- Maintain conjugation status as a dispatch key in the dispatch
  key set (TODO: audit all propagation of key_set to ensure that
  we don't propagate conjugation status when we shouldn't)

- Implement a few new functions for some other operations:

  - x.is_conj() tells you whether or not the conjugate bit is
    or not.  If not x.is_conj(), what's in memory reflects
    the semantic content of the tensor; if x.is_conj(),
    the imaginary values are negated.  This is implemented
    as a fastpath function similar to numel(); see
    #30774

  - x.view_as_real_physical() lets you view the underlying memory
    of a possibly conjugated tensor as its actual stored
    representation.  To interpret this result correctly, you
    will typically also have to query x.is_conj()

  - x.conj_physical_() will inplace flip the sign of the
    imaginary piece of the tensor.  This is a fairly useful
    operation, especially when getting conjugations to line
    up correctly. TODO: Consider renaming this to just conj_()

  - x.resolve_conj() plays of contiguous() but for conjugate views:
    if x.is_conj(), it will return a new tensor with the conjugation
    done in memory.

- Disable view_as_real() for conjugated tensors.  This change is
  necessary because conjugation is a concept only for complex
  tensors; on real tensors, there is no way to say "view this
  memory but negate every Nth element".  Most notably, this
  means x.imag no longer works on conjugated tensors; instead
  you should do x.resolve_conj().imag instead.

- Implement a backend fallback on the conjugate dispatch key.
  This fallback works for all non-view operations.  The general
  recipe is to take each tensor argument that is_conj() and
  resolve_conj() them.  If an argument is a mutable inplace argument,
  we instead conj_physical_() inplace, set_conj(False) and then
  do our operation; on the way out, we then invert this operation.

TODO: User-level docs

Signed-off-by: Edward Z. Yang <[email protected]>

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Sep 18, 2020
Based off of bdhirsch's prototype at #43702

Conjugate view tensor changes the semantics of x.conj() to return a view
of the original tensor, rather than immediately performing the
conjugation (aka, it implements a form of lazy evaluation for
conjugation).  This permits conjugations to be fused with later
operations that occur; e.g., matrix multiply, where BLAS libraries
typically all for a conjugate-transpose first argument.

The implementation strategy of this PR:

- Maintain conjugation status as a dispatch key in the dispatch
  key set (TODO: audit all propagation of key_set to ensure that
  we don't propagate conjugation status when we shouldn't)

- Implement a few new functions for some other operations:

  - x.is_conj() tells you whether or not the conjugate bit is
    or not.  If not x.is_conj(), what's in memory reflects
    the semantic content of the tensor; if x.is_conj(),
    the imaginary values are negated.  This is implemented
    as a fastpath function similar to numel(); see
    #30774

  - x.view_as_real_physical() lets you view the underlying memory
    of a possibly conjugated tensor as its actual stored
    representation.  To interpret this result correctly, you
    will typically also have to query x.is_conj()

  - x.conj_physical_() will inplace flip the sign of the
    imaginary piece of the tensor.  This is a fairly useful
    operation, especially when getting conjugations to line
    up correctly. TODO: Consider renaming this to just conj_()

  - x.resolve_conj() plays of contiguous() but for conjugate views:
    if x.is_conj(), it will return a new tensor with the conjugation
    done in memory.

- Disable view_as_real() for conjugated tensors.  This change is
  necessary because conjugation is a concept only for complex
  tensors; on real tensors, there is no way to say "view this
  memory but negate every Nth element".  Most notably, this
  means x.imag no longer works on conjugated tensors; instead
  you should do x.resolve_conj().imag instead.

- Implement a backend fallback on the conjugate dispatch key.
  This fallback works for all non-view operations.  The general
  recipe is to take each tensor argument that is_conj() and
  resolve_conj() them.  If an argument is a mutable inplace argument,
  we instead conj_physical_() inplace, set_conj(False) and then
  do our operation; on the way out, we then invert this operation.

TODO: User-level docs

ghstack-source-id: 726762d
Pull Request resolved: #44799

Signed-off-by: Edward Z. Yang <[email protected]>
@ezyang
ezyang requested a review from anjali411 September 18, 2020 17:38
@ezyang

ezyang commented Sep 18, 2020

Copy link
Copy Markdown
Contributor Author

cc @boeddeker

// call it a day.
// 2. Inplace operation. Desugar x.add_(2) into x.conj_().add_(2).conj_().
// Materialize other inputs as in (1).
// 3. Out-of-place operation. Desugar add(x, 2, out=y) into y.copy_(add(x, 2))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This is not really Out of place. Inplace via out? haha


for (int64_t i = 0; i < num_arguments; ++i) {
auto& ivalue = (*stack)[stack_start + i];
if (!ivalue.isTensor()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are TensorList handled at this level? Are they already unpacked?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not handled, this is a bug.

}
return at::_conj(self);
Tensor self_;
auto impl = c10::make_intrusive<TensorImpl>(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this expected to be different from self.variable_data() + setting conj?

Comment thread tools/autograd/derivatives.yaml Outdated
- name: view(Tensor(a) self, int[] size) -> Tensor(a)
self: grad.reshape(self.sizes())

# When result1 is true, this is effectively a fused conj() and view_as_real

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no result1 here?

Comment thread tools/autograd/load_derivatives.py Resolved
@boeddeker

Copy link
Copy Markdown
Contributor

Here, just some of my thoughts:

  • Is it possible for a user to easily see what happens? It sounds like many magic in the background (e.g. when does it work, that conj was not explicit executed or how does a user know if a particular operation handles the conj flag or uses the fallback).
  • What happens for the backward pass? Is the non conjugate and the conjugate kept in the memory (e.g. x.conj() * x)?
  • How about adding a negative flag? It is similar to the conjugate and it would simplify the accessing of the imag property. I am not sure how often this happens, but it could have also a small positive effect for real operations.
  • x.view_as_real_physical(): I am not sure, what this function does, but is with real the real part of a complex number meant (I expect not)? If not, I would suggest finding a name, that does not contain the word real (It may lead to confusion). When working with complex numbers, IMHO the words complex and real should be reserved for the complex numbers.
  • x.resolve_conj().imag: This is a confusing call. It would lead to much boilerplate code and unexpected behavior. I know "Explicit is better than implicit", but this is an implicit technique and making some parts implicit and some explicit is confusing.
  • What happens, when an operation uses the fallback and a tensor is used two times (e.g. y = x.conj(); z = y * y (Assume __mul__ would not support the conj flag)). Is then the conjugate calculated two times?

@ezyang

ezyang commented Sep 21, 2020

Copy link
Copy Markdown
Contributor Author

Is it possible for a user to easily see what happens? It sounds like many magic in the background (e.g. when does it work, that conj was not explicit executed or how does a user know if a particular operation handles the conj flag or uses the fallback).

I don't know a good way to surface this. The semantics of conj are fairly simple: it never does work, it always operates lazily. But whether or not you managed to hit a fused kernel or not is not something that I really know how to surface naturally. I think in the past we've talked about having some sort of logging to let people know when you hit a slow path, and you can also find things about this by running the autograd profiler (or at least, you should be able to); however, giving a warning every time we explicitly materialize a conj will probably be too much for most users.

What happens for the backward pass? Is the non conjugate and the conjugate kept in the memory (e.g. x.conj() * x)?

Only one is kept! A big benefit, thanks for telling us about it :)

How about adding a negative flag? It is similar to the conjugate and it would simplify the accessing of the imag property. I am not sure how often this happens, but it could have also a small positive effect for real operations.

Yes, between this and your comment about x.resolve_conj().imag, it sounds like we should directly implement negative flag today, rather than waiting later. I guess it doesn't have to be efficient or particularly well integrated, which means that the code here wouldn't be too large. If we did this, then your x.resolve_conj() problem would also be solved.

x.view_as_real_physical(): I am not sure, what this function does, but is with real the real part of a complex number meant (I expect not)? If not, I would suggest finding a name, that does not contain the word real (It may lead to confusion). When working with complex numbers, IMHO the words complex and real should be reserved for the complex numbers.

Ah, this is a more general API problem. view_as_real() is our current naming for reinterpreting a C tensor as a R^2 tensor; so view_as_real_physical() does the same thing but disregarding the conjugation status (because I don't have a way to do a view in R^2 but only have every other column be negative.) Do you think view_as_r2 would be clearer?

What happens, when an operation uses the fallback and a tensor is used two times (e.g. y = x.conj(); z = y * y (Assume mul would not support the conj flag)). Is then the conjugate calculated two times?

Yes, conjugate is calculated two times, unless the operation supported fusion.

@boeddeker

Copy link
Copy Markdown
Contributor

Thank you for the answers.

I don't know a good way to surface this. The semantics of conj are fairly simple: it never does work, it always operates lazily. But whether or not you managed to hit a fused kernel or not is not something that I really know how to surface naturally. I think in the past we've talked about having some sort of logging to let people know when you hit a slow path, and you can also find things about this by running the autograd profiler (or at least, you should be able to); however, giving a warning every time we explicitly materialize a conj will probably be too much for most users.

Thanks for the explanation. Yes, letting the user know what happened is difficult. Warnings are maybe too verbose and difficult to track.
How about exposing this information with the help of the backward graph?
When you visualize the backward graph and it shows the fused operations, you get an idea how good your code is.
(Afaik has pytorch at the moment no official tool to visualize the backward graph: https://discuss.pytorch.org/t/print-autograd-graph/692/7).

Only one is kept! A big benefit, thanks for telling us about it :)

That is great.

Yes, between this and your comment about x.resolve_conj().imag, it sounds like we should directly implement negative flag today, rather than waiting later. I guess it doesn't have to be efficient or particularly well integrated, which means that the code here wouldn't be too large. If we did this, then your x.resolve_conj() problem would also be solved.

I am not sure, where it would be used. Depending on this, it may have to be efficient.
When it is only set with .conj().imag or something like set_neg it has no effect to existing code, but changing - tensor may change existing code.
Nevertheless, adding this would lead to a cleaner complex API.

Ah, this is a more general API problem. view_as_real() is our current naming for reinterpreting a C tensor as a R^2 tensor; so view_as_real_physical() does the same thing but disregarding the conjugation status (because I don't have a way to do a view in R^2 but only have every other column be negative.) Do you think view_as_r2 would be clearer?

Ah, now I get the intention for the name. It is probably difficult to find the right name for this.
In the past I used view_as_float, since numpy is limited to float types, when using complex numbers.
Something like view_complex_as_r2_vector or view_complex_as_real_vector would be more verbose, but I am not sure, if they are better.

Yes, conjugate is calculated two times, unless the operation supported fusion.

So this is a small drawback of the current implementation.
I was hoping that the "python" variable holds the non-conjugate tensor and a lazy attribute that is used when an operation doesn't support fusion. But I am not familiar with the implementation of the python tensor. So it is probably impossible with the design.

@ezyang

ezyang commented Sep 21, 2020

Copy link
Copy Markdown
Contributor Author

I was hoping that the "python" variable holds the non-conjugate tensor and a lazy attribute that is used when an operation doesn't support fusion. But I am not familiar with the implementation of the python tensor. So it is probably impossible with the design.

Yeah, this design explicitly duplicates work. One way this is observable, is that if you do an inplace operation on a conjugate view, the underlying base gets updated too. Lazy semantics wouldn't give you that.

The lazy attribute is a valid alternative in the design space, but it is not too easy to implement correctly in a multithreaded setting. The problem is that y = x.conj() may be accessed concurrently from multiple threads, and we must ensure that the instantiation of the lazy tensor doesn't cause race condition between the threads, which implies some sort of synchronization. It is known how to do this efficiently (e.g. Section 8 of https://www.microsoft.com/en-us/research/wp-content/uploads/2009/09/multicore-ghc.pdf ) but conjugate views avoided this problem entirely, so I had guessed that maybe we should do it instead. Wondering if this triggered any further thoughts.

@boeddeker

Copy link
Copy Markdown
Contributor

Yeah, this design explicitly duplicates work. One way this is observable, is that if you do an inplace operation on a conjugate view, the underlying base gets updated too. Lazy semantics wouldn't give you that.

I think my idea is slightly different from yours.
When I get your idea correct, the python object holds only one data object (I think on Pytorch it is called storage).
And this may be changed inplace, when one operation doesn't support fusion.

My idea was slightly different, the python object can hold two data objects:

class Tensor:
    def __init__(self, data):
        self.data = data
        self._conj_data = None
    @property
    def conj_data(self):
        if self._conj_data is None:
            self._conj_data = self.data.conj()
        return self._conj_data

In python this is thread save, because the assignment is atomic (Thanks to the GIL) and the garbage collector takes care of a potential race condition (i.e. delete the object that was first assigned to self._conj_data).

The lazy attribute is a valid alternative in the design space, but it is not too easy to implement correctly in a multithreaded setting. The problem is that y = x.conj() may be accessed concurrently from multiple threads, and we must ensure that the instantiation of the lazy tensor doesn't cause race condition between the threads, which implies some sort of synchronization. It is known how to do this efficiently (e.g. Section 8 of https://www.microsoft.com/en-us/research/wp-content/uploads/2009/09/multicore-ghc.pdf ) but conjugate views avoided this problem entirely, so I had guessed that maybe we should do it instead. Wondering if this triggered any further thoughts.

I was thinking about the "PostCheck" idea (Without knowing that name).
How likely is it, that you use a conjugate tensor multiple times and how likely, that you use it in different threads.
I think PyTorch does the following (Sorry, that I am not so familiar with the core of PyTorch):
Python triggers a sequential workload, that is sequentially executed (maybe async, but sequentially).
For the backward graph I am not sure, but when it is also sequentially, the potential duplicate execution of the conjugate operation when using "PostCheck" doesn't matter, because it rarely (or never) happens.

@ezyang

ezyang commented Sep 21, 2020

Copy link
Copy Markdown
Contributor Author

My idea was slightly different, the python object can hold two data objects:

Yep. Though, aren't you worried about memory usage? This suggests that when _conj_data gets filled, we should delete data, so that we don't force both the old data and the new data to be in memory.

How likely is it, that you use a conjugate tensor multiple times and how likely, that you use it in different threads.

I agree, the multithreaded situation is unlikely to happen. Most of my implementation difficulty is more to do with correctness: we must not segfault or data race when you use it from multiple threads. BTW I realized that https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.68.8868&rep=rep1&type=pdf is a better paper on the same subject as above (see Section 3).

The primary challenge seems to be that we have arbitrarily many codepaths that may observe the _conj_data. In particular, all operations that do fused conjugation operations will interact directly with _conj_data. So unlike in the paper I cited, where we only had to worry about data races between two threads that were going to evaluate the thunk and then write it back, we have to handle data races between all materialization operations, as well as operators which know how to fuse the conjugation. In particular, when is it safe to delete the old _conj_data? It's not safe to delete it at the end of a materialization operation, as there may be other fused kernels that are still accessing _conj_data during the process.

Here is something that might work:

  • In GHC, after a thunk is updated it is replaced by an indirection. This is required in their setting because in general the result data may not fit in the memory allocated to the thunk. In PyTorch, things are different because we have a uniform data representation for Tensors, so we can plausibly store all the information we need directly in TensorImpl. So instead, a conjugate tensor is a regular tensor that also records the original tensor (so we can do the operation). We should also store the version counter of the base tensor, so that we can detect when a mutation on the base tensor invalidates our conjugate reference.
  • We have to handle the data race between materializing a conjugate tensor, and a separate use of the conjugate tensor directly. There are two pieces of data we have to synchronize: the Tensor key set (which controls which kernel we dispatch to) and the intrusive pointer to the original tensor. Here is one possible way to handle the race:
    • Our first "test" is the presence of a conjugate bit in the key set. If it is present, we get dispatched to a different kernel. The conjugate bit is a conservative tests: a tensor may have already been materialized even though its conjugate bit is set; however, a tensor is guaranteed to be materialized if the conjugate bit is not set.
    • When we get into a fused kernel / materialize conjugate kernel, we now must do a second test for the conjugation status. This is done by weak intrusive pointer lock() on the original tensor; if successful, we (1) confirm that the tensor is conjugate, and (2) increment the refcount and get an owning reference to the unconjugated storage. We can now proceed to do the operation on the unconjugated version of the tensor. A test for the version counter should also occur at this point.
    • For materialize conjugate kernel, we first (1) populate the storage field of the tensor with the real value (this is non-atomic), (2) free the owning reference to the base tensor, (3) update the key set to delete the conjugate bit.
  • This scheme is not directly compositional with other lazy schemes. If we want it to be compositional, we would probably have to introduce a generic materialize() operation, and then force a materialization before we actually do our operation in question.

I must admit, while I believe this could work, and I believe that there may be other (non-conjugate) use cases that would benefit greatly from this model, I am unconvinced that this is the best choice for conjugate tensors. But we are kind of at a fork in the road regarding semantics: the semantics of this and conjugate views are different. In particular:

x = ... some complex tensor ...
y = x.conj()
y.copy_(z)

For conjugate lazy tensors, you would expect x to stay unchanged. However, for conjugate view tensors, x is changed.

Also, writing this example has made me realize that it is not sound to allow duplicate work if the user subsequently mutates the result of the conjugation, since two copies of the conjugate tensor is observable. So you really are going to have to proper locking when you materialize.

@boeddeker

Copy link
Copy Markdown
Contributor

Yep. Though, aren't you worried about memory usage? This suggests that when _conj_data gets filled, we should delete data, so that we don't force both the old data and the new data to be in memory.

Yes, I care about the memory, but mainly about the memory of the tensors hold in the backward graph.
It is non-trivial to remove them from the backward graph. In the forward pass it is easy to remove unused tensors.

When _conj_data is deleted after the lifetime of the python object, I don't see a clear overhead of this idea.
Yes, it consumes more data, because the original data is not deleted, but when would it be deleted?

I scrolled to some of my code and most of the time, the original data will be hold by another tensor.
So it cannot be deleted, while a forward operation uses the conjugated tensor.

Another thing you may want to consider is, that the code should not have unpredictable side effects:

y = x.conj()
if calculate_z:
     z = y * x   # Assume mul has no fusion of conj and mul
w = y @ x  # Assume matmul has fusion of conj and matmul implemented

Depending, whether z is calculated, the matmul operations is a fused operation or not.
And independent of the calculation of z, the memory consumption does not change.
The original data is kept.

For the following, I am not sure, what happens.
Assume again your proposal for the inplace change, and the above example, where z and w is calculated.
When the matmul operation doesn't use the fused operation, because the mul operation triggerd the materialization,
the gradient calculation is less optimal, because it introduces one more intermediate gradient.
Here I am not sure, if the gradient will be materialized or not (i.e. if it is an overhead or not).

I agree, the multithreaded situation is unlikely to happen. Most of my implementation difficulty is more to do with correctness: we must not segfault or data race when you use it from multiple threads.

I agree, avoiding segfault or data race should have the highest priority.
But making it efficient is not so important as long no error happens.

The primary challenge seems to be that we have arbitrarily many codepaths that may observe the _conj_data. In particular, all operations that do fused conjugation operations will interact directly with _conj_data.

The idea was the opposite. In the long term (maybe very long) no operation will see _conj_data and they use the non-conjugate data and apply the fused operation. The fused operation should always be faster (e.g. for cuda: one less kernel call).

When I understand you right, your biggest problem is, that you have two possible realizations for the data:
x and x.conj(). And you try to predict, how to exchange them, without informing the user.
I think this is a very difficult task and maybe cannot be solved.

I would first do some investigations, if there is an improvement, to only keep 1 realization of the data.
I expect holding both gives more advantages, because you most likely hold the original data also somewhere else.
When the user cares about the higher memory usage, a non-lazy conjugate can do the task.

Furthermore, (at least at python level) just holding different realizations is simple and only need minimal locking (In Python the GIL can do this).

At the moment, I am unsure, if this implicit implementation of conj is better than exposing a conjugate argument.
It seems quite complicated and has many side effects.

@ezyang

ezyang commented Sep 21, 2020

Copy link
Copy Markdown
Contributor Author

Yes, I care about the memory, but mainly about the memory of the tensors hold in the backward graph.
It is non-trivial to remove them from the backward graph. In the forward pass it is easy to remove unused tensors.

This is good to know. To put it differently, if you have x = y.conj() and you care about not having either in memory, you will simply arrange for both x and y to get deleted. No problem. But then if x and y both get captured by the backwards pass (because they were used as part of some other computations), now you have no good solution, since there's no way to tell backward "hey, don't capture both of x and y".

I scrolled to some of my code and most of the time, the original data will be hold by another tensor.

If it's public, linking it from this discussion would be very helpful :)

Another thing you may want to consider is, that the code should not have unpredictable side effects:

...

Here I am not sure, if the gradient will be materialized or not (i.e. if it is an overhead or not).

In the scheme I described in my post, it would be materialized aka have overhead. In contrast, conjugate views wouldn't have this problem.

I thought about your solution to repair this problem. I think this sentence sums it up nicely:

When I understand you right, your biggest problem is, that you have two possible realizations for the data: x and x.conj(). And you try to predict, how to exchange them, without informing the user.
I think this is a very difficult task and maybe cannot be solved.

We can describe my two approaches in terms of how they make predictions about this exchange:

  • Conjugate view tensors (as proposed by this PR) say, "Always keep x until the very latest moment, when you have to do the computation and there is no more time to wait." In PL terms, we'd say this is call-by-need evaluation.
  • Conjugate lazy tensors (as described in my comment) say, "Keep x until the first time we need to materialize it; then swap it with x.conj() and use that from then on." This is lazy evaluation.

I think you are advancing the following third proposal:

  • Conjugate cached tensors: "Always keep x. If we need to materialize it, compute x.conj, and keep that too. Use either x or x.conj depending on whether or not the operator supports fused operations, but preferring x." In the long term, no one needs to materialize (BTW, this is unrealistic, IMO), and so x.conj ends up never getting materialized.

In this third proposal, we also have to decide whether or not you have view semantics (mutating x.conj() affects x) or clone semantics (mutating x.conj() has no effect on x). Due to the materialized x.conj(), view semantics would be difficult, although still possible (using version counters). But it is still very tricky. For example, in your example, if z participated in backwards, then you would have ended up with both x and x.conj() saved for backwards (indeed, only conjugate views save you, at the cost of a bit more recompute).

Furthermore, (at least at python level) just holding different realizations is simple and only need minimal locking (In Python the GIL can do this).

Alas, I need this to work in C++ only XD. This is one place where you probably don't care, but for the good of the framework we need to make sure this is handled correctly.

At the moment, I am unsure, if this implicit implementation of conj is better than exposing a conjugate argument.

Yes. This is something that I am worried about too. Right now, I think it is worth it, but mostly because I think the mathematicians in the audience will get really irritated at having to translate all of their code into using explicit conjugate flags. Chances are they'll just make some wrapper object to handle it... and if they're going to do that, we might as well do it properly for them in framework.

I do want to reiterate, that I feel that lazy conjugate views (which are implemented in this PR) are a lot simpler than lazy conjugate tensors. Their primary downside is duplicated work materializing conjugate, but as you say, if in the long term we add fusion to most operators, you will no longer have duplicated work. (Also, I suspect one could always add a cache on top later as a performance optimization; though we do have to make a call on clone or view semantics sooner rather than later.) What do you think?

@boeddeker

Copy link
Copy Markdown
Contributor

Thanks, your explanation for conjugate view tensors and conjugate lazy tensors helped me.
I mixed them.

This is good to know. To put it differently, if you have x = y.conj() and you care about not having either in memory, you will simply arrange for both x and y to get deleted. No problem. But then if x and y both get captured by the backwards pass (because they were used as part of some other computations), now you have no good solution, since there's no way to tell backward "hey, don't capture both of x and y".

I thought about something like torch.utils.checkpoint.checkpoint, so that y would not be kept.
After your explanation, of view vs lazy, I think something like that is probably difficult/impossible to implement.

If it's public, linking it from this discussion would be very helpful :)

Sure, I can share some pointers to our code, but it is numpy code and the use case is audio/speech:

In this third proposal, we also have to decide whether or not you have view semantics (mutating x.conj() affects x) or clone semantics (mutating x.conj() has no effect on x). Due to the materialized x.conj(), view semantics would be difficult, although still possible (using version counters). But it is still very tricky. For example, in your example, if z participated in backwards, then you would have ended up with both x and x.conj() saved for backwards (indeed, only conjugate views save you, at the cost of a bit more recompute).

I must say, I rarely think about inplace operations in NN code. Using no inplace operations worked for me until now.
For the x.conj() I hopped, that it is possible to access the actual value at the low level code (similar to conjugate view tensors), but it is kept for potential second access as temporary object attached to the python object.
Maybe this is to complicated to realize. (You called this cache for conjugate view tensors)

Alas, I need this to work in C++ only XD. This is one place where you probably don't care, but for the good of the framework we need to make sure this is handled correctly.

Yes, I know. But I mainly write python code and I don't know much of the internals of PyTorch. So I can only guess how difficult it is to realize it in C++ and getting it working in a large framework (I try to make careful statements and I know not every python code can easily be translated, especially when threads and garbage collection is involved.).

Yes. This is something that I am worried about too. Right now, I think it is worth it, but mostly because I think the mathematicians in the audience will get really irritated at having to translate all of their code into using explicit conjugate flags. Chances are they'll just make some wrapper object to handle it... and if they're going to do that, we might as well do it properly for them in framework.

At the moment, I must say, when I translate code to pytorch I have to do mayor changes.
For the gradient memory optimizations it would be ok to add conjugate flags.
There is already (or still) a large API difference, some operations aren't fully optimized (e.g. einsum handles manipulated strides better than matmul) and having a gradient requires also some changes.

So explicit conjugate flags, would at least make it obvious, that the optimal implementation is used.

I do want to reiterate, that I feel that lazy conjugate views (which are implemented in this PR) are a lot simpler than lazy conjugate tensors. Their primary downside is duplicated work materializing conjugate, but as you say, if in the long term we add fusion to most operators, you will no longer have duplicated work. (Also, I suspect one could always add a cache on top later as a performance optimization; though we do have to make a call on clone or view semantics sooner rather than later.) What do you think?

At the moment, I think using conjugate view tensors looks like a reasonable trade off between realizable and good performance.
Compared to conjugate lazy tensors it doesn't change its internal state (problem with parallel and "predictable" code) and it easily fit to the gradient calculations.

Also, I suspect one could always add a cache on top later as a performance optimization

When you add the cache, you arrive at my suggestion :), but with a better C++ implementation.

Based off of bdhirsch's prototype at #43702

Conjugate view tensor changes the semantics of x.conj() to return a view
of the original tensor, rather than immediately performing the
conjugation (aka, it implements a form of lazy evaluation for
conjugation).  This permits conjugations to be fused with later
operations that occur; e.g., matrix multiply, where BLAS libraries
typically all for a conjugate-transpose first argument.

The implementation strategy of this PR:

- Maintain conjugation status as a dispatch key in the dispatch
  key set (TODO: audit all propagation of key_set to ensure that
  we don't propagate conjugation status when we shouldn't)

- Implement a few new functions for some other operations:

  - x.is_conj() tells you whether or not the conjugate bit is
    or not.  If not x.is_conj(), what's in memory reflects
    the semantic content of the tensor; if x.is_conj(),
    the imaginary values are negated.  This is implemented
    as a fastpath function similar to numel(); see
    #30774

  - x.view_as_real_physical() lets you view the underlying memory
    of a possibly conjugated tensor as its actual stored
    representation.  To interpret this result correctly, you
    will typically also have to query x.is_conj()

  - x.conj_physical_() will inplace flip the sign of the
    imaginary piece of the tensor.  This is a fairly useful
    operation, especially when getting conjugations to line
    up correctly. TODO: Consider renaming this to just conj_()

  - x.resolve_conj() plays of contiguous() but for conjugate views:
    if x.is_conj(), it will return a new tensor with the conjugation
    done in memory.

- Disable view_as_real() for conjugated tensors.  This change is
  necessary because conjugation is a concept only for complex
  tensors; on real tensors, there is no way to say "view this
  memory but negate every Nth element".  Most notably, this
  means x.imag no longer works on conjugated tensors; instead
  you should do x.resolve_conj().imag instead.

- Implement a backend fallback on the conjugate dispatch key.
  This fallback works for all non-view operations.  The general
  recipe is to take each tensor argument that is_conj() and
  resolve_conj() them.  If an argument is a mutable inplace argument,
  we instead conj_physical_() inplace, set_conj(False) and then
  do our operation; on the way out, we then invert this operation.

TODO: User-level docs

Signed-off-by: Edward Z. Yang <[email protected]>

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Sep 22, 2020
Based off of bdhirsch's prototype at #43702

Conjugate view tensor changes the semantics of x.conj() to return a view
of the original tensor, rather than immediately performing the
conjugation (aka, it implements a form of lazy evaluation for
conjugation).  This permits conjugations to be fused with later
operations that occur; e.g., matrix multiply, where BLAS libraries
typically all for a conjugate-transpose first argument.

The implementation strategy of this PR:

- Maintain conjugation status as a dispatch key in the dispatch
  key set (TODO: audit all propagation of key_set to ensure that
  we don't propagate conjugation status when we shouldn't)

- Implement a few new functions for some other operations:

  - x.is_conj() tells you whether or not the conjugate bit is
    or not.  If not x.is_conj(), what's in memory reflects
    the semantic content of the tensor; if x.is_conj(),
    the imaginary values are negated.  This is implemented
    as a fastpath function similar to numel(); see
    #30774

  - x.view_as_real_physical() lets you view the underlying memory
    of a possibly conjugated tensor as its actual stored
    representation.  To interpret this result correctly, you
    will typically also have to query x.is_conj()

  - x.conj_physical_() will inplace flip the sign of the
    imaginary piece of the tensor.  This is a fairly useful
    operation, especially when getting conjugations to line
    up correctly. TODO: Consider renaming this to just conj_()

  - x.resolve_conj() plays of contiguous() but for conjugate views:
    if x.is_conj(), it will return a new tensor with the conjugation
    done in memory.

- Disable view_as_real() for conjugated tensors.  This change is
  necessary because conjugation is a concept only for complex
  tensors; on real tensors, there is no way to say "view this
  memory but negate every Nth element".  Most notably, this
  means x.imag no longer works on conjugated tensors; instead
  you should do x.resolve_conj().imag instead.

- Implement a backend fallback on the conjugate dispatch key.
  This fallback works for all non-view operations.  The general
  recipe is to take each tensor argument that is_conj() and
  resolve_conj() them.  If an argument is a mutable inplace argument,
  we instead conj_physical_() inplace, set_conj(False) and then
  do our operation; on the way out, we then invert this operation.

TODO: User-level docs

ghstack-source-id: 9f12c93
Pull Request resolved: #44799

Signed-off-by: Edward Z. Yang <[email protected]>
Based off of bdhirsch's prototype at #43702

Conjugate view tensor changes the semantics of x.conj() to return a view
of the original tensor, rather than immediately performing the
conjugation (aka, it implements a form of lazy evaluation for
conjugation).  This permits conjugations to be fused with later
operations that occur; e.g., matrix multiply, where BLAS libraries
typically all for a conjugate-transpose first argument.

The implementation strategy of this PR:

- Maintain conjugation status as a dispatch key in the dispatch
  key set (TODO: audit all propagation of key_set to ensure that
  we don't propagate conjugation status when we shouldn't)

- Implement a few new functions for some other operations:

  - x.is_conj() tells you whether or not the conjugate bit is
    or not.  If not x.is_conj(), what's in memory reflects
    the semantic content of the tensor; if x.is_conj(),
    the imaginary values are negated.  This is implemented
    as a fastpath function similar to numel(); see
    #30774

  - x.view_as_real_physical() lets you view the underlying memory
    of a possibly conjugated tensor as its actual stored
    representation.  To interpret this result correctly, you
    will typically also have to query x.is_conj()

  - x.conj_physical_() will inplace flip the sign of the
    imaginary piece of the tensor.  This is a fairly useful
    operation, especially when getting conjugations to line
    up correctly. TODO: Consider renaming this to just conj_()

  - x.resolve_conj() plays of contiguous() but for conjugate views:
    if x.is_conj(), it will return a new tensor with the conjugation
    done in memory.

- Disable view_as_real() for conjugated tensors.  This change is
  necessary because conjugation is a concept only for complex
  tensors; on real tensors, there is no way to say "view this
  memory but negate every Nth element".  Most notably, this
  means x.imag no longer works on conjugated tensors; instead
  you should do x.resolve_conj().imag instead.

- Implement a backend fallback on the conjugate dispatch key.
  This fallback works for all non-view operations.  The general
  recipe is to take each tensor argument that is_conj() and
  resolve_conj() them.  If an argument is a mutable inplace argument,
  we instead conj_physical_() inplace, set_conj(False) and then
  do our operation; on the way out, we then invert this operation.

TODO: User-level docs

Signed-off-by: Edward Z. Yang <[email protected]>

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Sep 22, 2020
Based off of bdhirsch's prototype at #43702

Conjugate view tensor changes the semantics of x.conj() to return a view
of the original tensor, rather than immediately performing the
conjugation (aka, it implements a form of lazy evaluation for
conjugation).  This permits conjugations to be fused with later
operations that occur; e.g., matrix multiply, where BLAS libraries
typically all for a conjugate-transpose first argument.

The implementation strategy of this PR:

- Maintain conjugation status as a dispatch key in the dispatch
  key set (TODO: audit all propagation of key_set to ensure that
  we don't propagate conjugation status when we shouldn't)

- Implement a few new functions for some other operations:

  - x.is_conj() tells you whether or not the conjugate bit is
    or not.  If not x.is_conj(), what's in memory reflects
    the semantic content of the tensor; if x.is_conj(),
    the imaginary values are negated.  This is implemented
    as a fastpath function similar to numel(); see
    #30774

  - x.view_as_real_physical() lets you view the underlying memory
    of a possibly conjugated tensor as its actual stored
    representation.  To interpret this result correctly, you
    will typically also have to query x.is_conj()

  - x.conj_physical_() will inplace flip the sign of the
    imaginary piece of the tensor.  This is a fairly useful
    operation, especially when getting conjugations to line
    up correctly. TODO: Consider renaming this to just conj_()

  - x.resolve_conj() plays of contiguous() but for conjugate views:
    if x.is_conj(), it will return a new tensor with the conjugation
    done in memory.

- Disable view_as_real() for conjugated tensors.  This change is
  necessary because conjugation is a concept only for complex
  tensors; on real tensors, there is no way to say "view this
  memory but negate every Nth element".  Most notably, this
  means x.imag no longer works on conjugated tensors; instead
  you should do x.resolve_conj().imag instead.

- Implement a backend fallback on the conjugate dispatch key.
  This fallback works for all non-view operations.  The general
  recipe is to take each tensor argument that is_conj() and
  resolve_conj() them.  If an argument is a mutable inplace argument,
  we instead conj_physical_() inplace, set_conj(False) and then
  do our operation; on the way out, we then invert this operation.

TODO: User-level docs

ghstack-source-id: ccf7019
Pull Request resolved: #44799

Signed-off-by: Edward Z. Yang <[email protected]>
Based off of bdhirsch's prototype at #43702

Conjugate view tensor changes the semantics of x.conj() to return a view
of the original tensor, rather than immediately performing the
conjugation (aka, it implements a form of lazy evaluation for
conjugation).  This permits conjugations to be fused with later
operations that occur; e.g., matrix multiply, where BLAS libraries
typically all for a conjugate-transpose first argument.

The implementation strategy of this PR:

- Maintain conjugation status as a dispatch key in the dispatch
  key set (TODO: audit all propagation of key_set to ensure that
  we don't propagate conjugation status when we shouldn't)

- Implement a few new functions for some other operations:

  - x.is_conj() tells you whether or not the conjugate bit is
    or not.  If not x.is_conj(), what's in memory reflects
    the semantic content of the tensor; if x.is_conj(),
    the imaginary values are negated.  This is implemented
    as a fastpath function similar to numel(); see
    #30774

  - x.view_as_real_physical() lets you view the underlying memory
    of a possibly conjugated tensor as its actual stored
    representation.  To interpret this result correctly, you
    will typically also have to query x.is_conj()

  - x.conj_physical_() will inplace flip the sign of the
    imaginary piece of the tensor.  This is a fairly useful
    operation, especially when getting conjugations to line
    up correctly. TODO: Consider renaming this to just conj_()

  - x.resolve_conj() plays of contiguous() but for conjugate views:
    if x.is_conj(), it will return a new tensor with the conjugation
    done in memory.

- Disable view_as_real() for conjugated tensors.  This change is
  necessary because conjugation is a concept only for complex
  tensors; on real tensors, there is no way to say "view this
  memory but negate every Nth element".  Most notably, this
  means x.imag no longer works on conjugated tensors; instead
  you should do x.resolve_conj().imag instead.

- Implement a backend fallback on the conjugate dispatch key.
  This fallback works for all non-view operations.  The general
  recipe is to take each tensor argument that is_conj() and
  resolve_conj() them.  If an argument is a mutable inplace argument,
  we instead conj_physical_() inplace, set_conj(False) and then
  do our operation; on the way out, we then invert this operation.

TODO: User-level docs

Signed-off-by: Edward Z. Yang <[email protected]>

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 26, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

TODO:
1. docs
2. handle tensorlist

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 27, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

TODO:
1. docs
2. handle tensorlist

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 27, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

TODO:
1. docs
2. handle tensorlist

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 27, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

TODO:
1. docs
2. handle tensorlist

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 27, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

TODO:
1. conjugate view RFC
2. Enable conj view testing for all OpInfos

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 27, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

TODO:
1. conjugate view RFC
2. Enable conj view testing for all OpInfos

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 27, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

TODO:
1. conjugate view RFC
2. Enable conj view testing for all OpInfos

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 28, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

TODO:
1. conjugate view RFC
2. Enable conj view testing for all OpInfos

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 29, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)

TODO:
1. conjugate view RFC


[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 29, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)

TODO:
1. conjugate view RFC


[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 29, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation. 


[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 30, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation. 


[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 30, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation. 


[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 30, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation. 


[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 30, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation. 


[ghstack-poisoned]
anjali411 added a commit that referenced this pull request May 5, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation. 


[ghstack-poisoned]
anjali411 added a commit that referenced this pull request May 5, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation. 


[ghstack-poisoned]
anjali411 added a commit that referenced this pull request May 5, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Differential Revision: [D28227315](https://our.internmc.facebook.com/intern/diff/D28227315)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request May 10, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e)  `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b)  Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Differential Revision: [D28227315](https://our.internmc.facebook.com/intern/diff/D28227315)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request May 11, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e)  `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b)  Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Differential Revision: [D28227315](https://our.internmc.facebook.com/intern/diff/D28227315)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request May 11, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e)  `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b)  Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Differential Revision: [D28227315](https://our.internmc.facebook.com/intern/diff/D28227315)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jun 3, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e)  `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b)  Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Differential Revision: [D28227315](https://our.internmc.facebook.com/intern/diff/D28227315)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jun 3, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e)  `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b)  Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Differential Revision: [D28227315](https://our.internmc.facebook.com/intern/diff/D28227315)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jun 3, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e)  `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b)  Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Differential Revision: [D28227315](https://our.internmc.facebook.com/intern/diff/D28227315)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jun 4, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e)  `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b)  Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Differential Revision: [D28227315](https://our.internmc.facebook.com/intern/diff/D28227315)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jun 4, 2021
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose). 

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API: 
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e)  `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b)  Everything else works as expected.
5. Testing: 
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)
 
NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Differential Revision: [D28227315](https://our.internmc.facebook.com/intern/diff/D28227315)

[ghstack-poisoned]
facebook-github-bot pushed a commit that referenced this pull request Jun 4, 2021
Summary:
Pull Request resolved: #54987

Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose).

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API:
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing:
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)

NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Test Plan: Imported from OSS

Reviewed By: VitalyFedyunin

Differential Revision: D28227315

Pulled By: anjali411

fbshipit-source-id: acab9402b9d6a970c6d512809b627a290c8def5f
deniskokarev pushed a commit to deniskokarev/pytorch that referenced this pull request Jun 9, 2021
Summary:
Pull Request resolved: pytorch#54987

Based off of ezyang (pytorch#44799) and bdhirsh (pytorch#43702) 's prototype:

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose).

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API:
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing:
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)

NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Test Plan: Imported from OSS

Reviewed By: VitalyFedyunin

Differential Revision: D28227315

Pulled By: anjali411

fbshipit-source-id: acab9402b9d6a970c6d512809b627a290c8def5f
@anjali411 anjali411 closed this Jul 16, 2021
@facebook-github-bot
facebook-github-bot deleted the gh/ezyang/839/head branch August 16, 2021 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed module: complex Related to complex number support in PyTorch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants