Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quantized tensor: add support for advanced indexing #49129

Closed
wants to merge 5 commits into from

Conversation

vkuzo
Copy link
Contributor

@vkuzo vkuzo commented Dec 10, 2020

Stack from ghstack:

Summary:

Implements support for the indexing of quantized tensors with lists of
dims, such as

xq_slice = xq[:, [0], :, :]

If helpful for reviewers, the things originally broken were, in order:

  1. computeDeviceType did not handle DispatchKey::QuantizedCPU (fix: added)
  2. quantization params were not present in TensorIterator::set_output so they can be used to properly create the quantized tensor (fix: created TensorQuantizationOptions and threaded it through the relevant places)
  3. index kernel was not enabled for quantized dtypes (fix: enable it)

Note: this PR only handles per-Tensor qparams. We don't expect to need this for per-channel qparams any time soon, ideally we can pay the eng cost for enabling that when it is needed.

Test Plan:

python test/test_quantization.py TestQuantizedOps.test_advanced_indexing

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: D25451651

Summary:

Implements support for the indexing of quantized tensors with lists of
dims, such as

```
xq_slice = xq[:, [0], :, :]
```

At least a few things need to happen before this being ready for review:
1. Verify if the general idea of `TensorAdditionalOptions` is the right abstraction
2. Verify if `TensorAdditionalOptions` needs the same style as `TensorOptions` (no optionals, etc)

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Dec 10, 2020
Summary:

Implements support for the indexing of quantized tensors with lists of
dims, such as

```
xq_slice = xq[:, [0], :, :]
```

At least a few things need to happen before this being ready for review:
1. Verify if the general idea of `TensorAdditionalOptions` is the right abstraction
2. Verify if `TensorAdditionalOptions` needs the same style as `TensorOptions` (no optionals, etc)

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 9242ec9ae63fdb54d07fe4e5d450515028cf86c2
Pull Request resolved: #49129
@dr-ci
Copy link

dr-ci bot commented Dec 10, 2020

💊 CI failures summary and remediations

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


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

🕵️ 3 new failures recognized by patterns

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

See CircleCI build pytorch_linux_xenial_py3_6_gcc5_4_build (1/3)

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

Dec 14 20:51:14 collect2: error: ld returned 1 exit status
Dec 14 20:51:12 make[1]: *** Waiting for unfinished jobs....
Dec 14 20:51:12 [ 86%] Linking CXX executable ../bin/conv_to_nnpack_transform_test
Dec 14 20:51:13 /var/lib/jenkins/workspace/build/lib/libtorch_cpu.so: undefined reference to `c10::impl::raw_local_dispatch_key_set'
Dec 14 20:51:13 collect2: error: ld returned 1 exit status
Dec 14 20:51:13 caffe2/CMakeFiles/conv_to_nnpack_transform_test.dir/build.make:105: recipe for target 'bin/conv_to_nnpack_transform_test' failed
Dec 14 20:51:13 make[2]: *** [bin/conv_to_nnpack_transform_test] Error 1
Dec 14 20:51:13 CMakeFiles/Makefile2:5350: recipe for target 'caffe2/CMakeFiles/conv_to_nnpack_transform_test.dir/all' failed
Dec 14 20:51:13 make[1]: *** [caffe2/CMakeFiles/conv_to_nnpack_transform_test.dir/all] Error 2
Dec 14 20:51:13 [ 86%] Linking CXX executable ../bin/depthwise3x3_conv_op_test
Dec 14 20:51:14 /var/lib/jenkins/workspace/build/lib/libtorch_cpu.so: undefined reference to `c10::impl::raw_local_dispatch_key_set'
Dec 14 20:51:14 collect2: error: ld returned 1 exit status
Dec 14 20:51:14 make[2]: *** [bin/depthwise3x3_conv_op_test] Error 1
Dec 14 20:51:14 caffe2/CMakeFiles/depthwise3x3_conv_op_test.dir/build.make:105: recipe for target 'bin/depthwise3x3_conv_op_test' failed
Dec 14 20:51:14 CMakeFiles/Makefile2:5436: recipe for target 'caffe2/CMakeFiles/depthwise3x3_conv_op_test.dir/all' failed
Dec 14 20:51:14 make[1]: *** [caffe2/CMakeFiles/depthwise3x3_conv_op_test.dir/all] Error 2
Dec 14 20:51:14 Makefile:138: recipe for target 'all' failed
Dec 14 20:51:14 make: *** [all] Error 2
Dec 14 20:51:14 -- Building version 1.8.0a0
Dec 14 20:51:14 cmake -DBUILD_ENVIRONMENT=pytorch-linux-xenial-py3.6-gcc5.4-build -DBUILD_PYTHON=True -DBUILD_TEST=True -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/var/lib/jenkins/workspace/torch -DCMAKE_PREFIX_PATH=/opt/conda/lib/python3.6/site-packages -DNUMPY_INCLUDE_DIR=/opt/conda/lib/python3.6/site-packages/numpy/core/include -DPYTHON_EXECUTABLE=/opt/conda/bin/python -DPYTHON_INCLUDE_DIR=/opt/conda/include/python3.6m -DPYTHON_LIBRARY=/opt/conda/lib/libpython3.6m.so.1.0 -DTORCH_BUILD_VERSION=1.8.0a0 -DUSE_LLVM=/opt/llvm -DUSE_NUMPY=True -DWERROR=1 /var/lib/jenkins/workspace
Dec 14 20:51:14 cmake --build . --target install --config Release -- -j 3
Dec 14 20:51:14 Traceback (most recent call last):

See CircleCI build pytorch_linux_xenial_cuda9_2_cudnn7_py3_gcc5_4_build (2/3)

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

Dec 14 17:31:42 sccache: error: couldn't connect to server
Dec 14 17:31:42 +++ eval 'extract_trap_cmd '
Dec 14 17:31:42 ++++ extract_trap_cmd
Dec 14 17:31:42 ++++ printf '%s\n' ''
Dec 14 17:31:42 +++ printf '%s\n' cleanup
Dec 14 17:31:42 ++ trap -- '
Dec 14 17:31:42 cleanup' EXIT
Dec 14 17:31:42 ++ [[ pytorch-linux-xenial-cuda9.2-cudnn7-py3-gcc5.4-build != *pytorch-win-* ]]
Dec 14 17:31:42 ++ which sccache
Dec 14 17:31:42 ++ sccache --stop-server
Dec 14 17:31:42 Stopping sccache server...
Dec 14 17:31:42 sccache: error: couldn't connect to server
Dec 14 17:31:42 sccache: caused by: Connection refused (os error 111)
Dec 14 17:31:42 ++ true
Dec 14 17:31:42 ++ rm /var/lib/jenkins/sccache_error.log
Dec 14 17:31:42 rm: cannot remove '/var/lib/jenkins/sccache_error.log': No such file or directory
Dec 14 17:31:42 ++ true
Dec 14 17:31:42 ++ [[ pytorch-linux-xenial-cuda9.2-cudnn7-py3-gcc5.4-build == *rocm* ]]
Dec 14 17:31:42 ++ SCCACHE_ERROR_LOG=/var/lib/jenkins/sccache_error.log
Dec 14 17:31:42 ++ SCCACHE_IDLE_TIMEOUT=1200
Dec 14 17:31:42 ++ RUST_LOG=sccache::server=error
Dec 14 17:31:42 ++ sccache --start-server

See CircleCI build pytorch_linux_xenial_py3_clang5_asan_test2 (3/3)

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

Dec 14 21:16:09 RuntimeError: test_quantization failed!
Dec 14 21:16:07 Generated XML report: test-reports/dist-gloo/TEST-quantization.test_quantized_tensor.TestQuantizedTensor-20201214204712.xml
Dec 14 21:16:07 Generated XML report: test-reports/dist-gloo/TEST-quantization.test_workflow_module.TestRecordHistogramObserver-20201214204712.xml
Dec 14 21:16:07 Generated XML report: test-reports/dist-gloo/TEST-quantization.test_backward_compatibility.TestSerialization-20201214204712.xml
Dec 14 21:16:07 Generated XML report: test-reports/dist-gloo/TEST-quantization.test_quantized_module.TestStaticQuantizedModule-20201214204712.xml
Dec 14 21:16:07 Generated XML report: test-reports/dist-gloo/TEST-quantization.test_quantized_op.TestQNNPackOps-20201214204712.xml
Dec 14 21:16:09 Traceback (most recent call last):
Dec 14 21:16:09   File "test/run_test.py", line 896, in <module>
Dec 14 21:16:09     main()
Dec 14 21:16:09   File "test/run_test.py", line 879, in main
Dec 14 21:16:09     raise RuntimeError(err_message)
Dec 14 21:16:09 RuntimeError: test_quantization failed!
Dec 14 21:16:09 + cleanup
Dec 14 21:16:09 + retcode=1
Dec 14 21:16:09 + set +x
Dec 14 21:16:09 =================== sccache compilation log ===================
Dec 14 21:16:09 =========== If your build fails, please take a look at the log above for possible reasons ===========
Dec 14 21:16:10 Compile requests                      0
Dec 14 21:16:10 Compile requests executed             0
Dec 14 21:16:10 Cache hits                            0
Dec 14 21:16:10 Cache misses                          0
Dec 14 21:16:10 Cache timeouts                        0

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.

This comment has been revised 17 times.

Summary:

Implements support for the indexing of quantized tensors with lists of
dims, such as

```
xq_slice = xq[:, [0], :, :]
```

At least a few things need to happen before this being ready for review:
1. Verify if the general idea of `TensorAdditionalOptions` is the right abstraction
2. Verify if `TensorAdditionalOptions` needs the same style as `TensorOptions` (no optionals, etc)

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Dec 10, 2020
Summary:

Implements support for the indexing of quantized tensors with lists of
dims, such as

```
xq_slice = xq[:, [0], :, :]
```

At least a few things need to happen before this being ready for review:
1. Verify if the general idea of `TensorAdditionalOptions` is the right abstraction
2. Verify if `TensorAdditionalOptions` needs the same style as `TensorOptions` (no optionals, etc)

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 10e51c59583e07ae5c42307c8879d6dd6a368422
Pull Request resolved: #49129
@vkuzo vkuzo changed the title [wip] quantized tensor: add support for advanced indexing quantized tensor: add support for advanced indexing Dec 10, 2020
if (options.dtype() == at::kQInt8 || options.dtype() == at::kQUInt8 ||
options.dtype() == at::kQInt32) {
// get the first input and copy its quantization parameters
const auto& first_input = operands_[num_outputs_];
Copy link
Contributor

Choose a reason for hiding this comment

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

So what if the quantization parameters on the two tensors are different? That seems like a totally reasonable situation, and then copying the quantization parameters from the first input seems like a totally arbitrary choice.

Copy link
Contributor

Choose a reason for hiding this comment

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

If the correct quantization of the output tensor is something that varies from operator to operator, it may make sense to force kernels to do the computation of the quantization. There is some precedent for doing this in TensorIterator with the static_shape parameter, where kernels can say "Hey, I know you've got some built-in shape computation, but I actually happen to know what the output shape is, please use this." I could easily imagine something similar for quantization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I don't think the current solution is super clean, I'm also not sure if the alternative would be better.

The two high level ways I saw to do this were:

  1. add a quantized path to the current fp32 indexing logic (current PR). This reuses the size calculations and the kernels, but has to add some metadata for quantized tensors in places where it previously did not exist.
  2. dispatch to something like quantized_index, which would have to reimplement the indexing logic (with some pieces potentially reusable from fp32, but likely not all)

Thoughts on any options I might be missing here? Does 1 sound like the right call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for now, it's option 1, with the non-relevant parts asserted out, but I'm flexible

Copy link
Contributor

Choose a reason for hiding this comment

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

@vkuzo The nuance here is that the code paths you are editing in TensorIterator aren't just for fp32 indexing: they are for every unary, binary and reduction operation in PyTorch. So if you want to add something here, there is an obligation to at least have some plausible argument why the logic here is appropriate for all other operations.

I don't mind option one, but this PR ain't it. An implementation that more closely follows the idea of (1) is to take the existing indexing kernel (not in TensorIterator) and program TensorIterator on what the intended quantization result is.

} else {
// non-quantized path
op.tensor = at::empty(sizes, options);
}
} else {
op.tensor = at::empty_strided(sizes, strides, options);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Below, there is logic for handling what happens in the out= case. Imagine that you do indexing into a pre-existing quantized tensor. What should the quantization parameters be? What if the tensor is to be resized in this situation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

asserted it out for now

@ezyang
Copy link
Contributor

ezyang commented Dec 11, 2020

The change to MetaBase::set_output looks incomplete. Oddly, the CI is passing, this is probably because none of the quantized operations have been made structured yet.

Summary:

Implements support for the indexing of quantized tensors with lists of
dims, such as

```
xq_slice = xq[:, [0], :, :]
```

If helpful for reviewers, the things originally broken were, in order:
1. `computeDeviceType` did not handle `DispatchKey::QuantizedCPU` (fix: added)
2. quantization params were not present in `TensorIterator::set_output` so they can be used to properly create the quantized tensor (fix: created `TensorQuantizationOptions` and threaded it through the relevant places)
3. `index` kernel was not enabled for quantized dtypes (fix: enable it)

Note: this PR only handles per-Tensor qparams.  We don't expect to need this for per-channel qparams any time soon, ideally we can pay the eng cost for enabling that when it is needed.

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
@vkuzo
Copy link
Contributor Author

vkuzo commented Dec 12, 2020

The change to MetaBase::set_output looks incomplete. Oddly, the CI is passing, this is probably because none of the quantized operations have been made structured yet.

to clarify, do you mean accounting for the changes in #48718? Yes, that was not in the original PR, but is there in the latest update.

@vkuzo vkuzo requested a review from ezyang December 12, 2020 23:16
Summary:

Implements support for the indexing of quantized tensors with lists of
dims, such as

```
xq_slice = xq[:, [0], :, :]
```

If helpful for reviewers, the things originally broken were, in order:
1. `computeDeviceType` did not handle `DispatchKey::QuantizedCPU` (fix: added)
2. quantization params were not present in `TensorIterator::set_output` so they can be used to properly create the quantized tensor (fix: created `TensorQuantizationOptions` and threaded it through the relevant places)
3. `index` kernel was not enabled for quantized dtypes (fix: enable it)

Note: this PR only handles per-Tensor qparams.  We don't expect to need this for per-channel qparams any time soon, ideally we can pay the eng cost for enabling that when it is needed.

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Dec 12, 2020
Summary:

Implements support for the indexing of quantized tensors with lists of
dims, such as

```
xq_slice = xq[:, [0], :, :]
```

At least a few things need to happen before this being ready for review:
1. Verify if the general idea of `TensorAdditionalOptions` is the right abstraction
2. Verify if `TensorAdditionalOptions` needs the same style as `TensorOptions` (no optionals, etc)

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 0966cb15742d8e6084cc7d7755de14b0e40b7d76
Pull Request resolved: #49129
…nced indexing"


Summary:

Implements support for the indexing of quantized tensors with lists of
dims, such as

```
xq_slice = xq[:, [0], :, :]
```

If helpful for reviewers, the things originally broken were, in order:
1. `computeDeviceType` did not handle `DispatchKey::QuantizedCPU` (fix: added)
2. quantization params were not present in `TensorIterator::set_output` so they can be used to properly create the quantized tensor (fix: created `TensorQuantizationOptions` and threaded it through the relevant places)
3. `index` kernel was not enabled for quantized dtypes (fix: enable it)

Note: this PR only handles per-Tensor qparams.  We don't expect to need this for per-channel qparams any time soon, ideally we can pay the eng cost for enabling that when it is needed.

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Dec 14, 2020
Summary:

Implements support for the indexing of quantized tensors with lists of
dims, such as

```
xq_slice = xq[:, [0], :, :]
```

At least a few things need to happen before this being ready for review:
1. Verify if the general idea of `TensorAdditionalOptions` is the right abstraction
2. Verify if `TensorAdditionalOptions` needs the same style as `TensorOptions` (no optionals, etc)

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: d4ed3defbd5be7729f5466f50c108438ef4fe77e
Pull Request resolved: #49129
vkuzo added a commit that referenced this pull request Dec 14, 2020
Summary:

This is less ambitious redo of
#49129.

We make the

```
xq_slice = xq[:, [0], :, :]
```

indexing syntax work if `xq` is a quantized Tensor.  For now, we are
making the code not crash, with an in efficient `dq -> index -> q`
implementation.  A future PR can optimize performance by removing
the unnecessary memory copies (which will require some non-trivial
changes to TensorIterator).

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Dec 14, 2020
…for advanced indexing, try 2"

Summary:

This is less ambitious redo of
#49129.

We make the

```
xq_slice = xq[:, [0], :, :]
```

indexing syntax work if `xq` is a quantized Tensor.  For now, we are
making the code not crash, with an in efficient `dq -> index -> q`
implementation.  A future PR can optimize performance by removing
the unnecessary memory copies (which will require some non-trivial
changes to TensorIterator).

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Dec 14, 2020
…dexing, try 2"

Summary:

This is less ambitious redo of
#49129.

We make the

```
xq_slice = xq[:, [0], :, :]
```

indexing syntax work if `xq` is a quantized Tensor.  For now, we are
making the code not crash, with an in efficient `dq -> index -> q`
implementation.  A future PR can optimize performance by removing
the unnecessary memory copies (which will require some non-trivial
changes to TensorIterator).

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Dec 14, 2020
Summary:

This is less ambitious redo of
#49129.

We make the

```
xq_slice = xq[:, [0], :, :]
```

indexing syntax work if `xq` is a quantized Tensor.  For now, we are
making the code not crash, with an in efficient `dq -> index -> q`
implementation.  A future PR can optimize performance by removing
the unnecessary memory copies (which will require some non-trivial
changes to TensorIterator).

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 9540251c238e7eb1a61db4037b189493a6cca18d
Pull Request resolved: #49346
vkuzo added a commit that referenced this pull request Dec 14, 2020
…ed indexing, try 2"

Summary:

This is less ambitious redo of
#49129.

We make the

```
xq_slice = xq[:, [0], :, :]
```

indexing syntax work if `xq` is a quantized Tensor.  For now, we are
making the code not crash, with an in efficient `dq -> index -> q`
implementation.  A future PR can optimize performance by removing
the unnecessary memory copies (which will require some non-trivial
changes to TensorIterator).

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Dec 14, 2020
Summary:

This is less ambitious redo of
#49129.

We make the

```
xq_slice = xq[:, [0], :, :]
```

indexing syntax work if `xq` is a quantized Tensor.  For now, we are
making the code not crash, with an in efficient `dq -> index -> q`
implementation.  A future PR can optimize performance by removing
the unnecessary memory copies (which will require some non-trivial
changes to TensorIterator).

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: c319b525c3d8640027b7c0796331a4682559e2ab
Pull Request resolved: #49346
vkuzo added a commit that referenced this pull request Dec 16, 2020
…exing, try 2"

Summary:

This is less ambitious redo of
#49129.

We make the

```
xq_slice = xq[:, [0], :, :]
```

indexing syntax work if `xq` is a quantized Tensor.  For now, we are
making the code not crash, with an in efficient `dq -> index -> q`
implementation.  A future PR can optimize performance by removing
the unnecessary memory copies (which will require some non-trivial
changes to TensorIterator).

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Dec 16, 2020
…exing, try 2"

Summary:

This is less ambitious redo of
#49129.

We make the

```
xq_slice = xq[:, [0], :, :]
```

indexing syntax work if `xq` is a quantized Tensor.  For now, we are
making the code not crash, with an in efficient `dq -> index -> q`
implementation.  A future PR can optimize performance by removing
the unnecessary memory copies (which will require some non-trivial
changes to TensorIterator).

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Dec 16, 2020
Summary:

This is less ambitious redo of
#49129.

We make the

```
xq_slice = xq[:, [0], :, :]
```

indexing syntax work if `xq` is a quantized Tensor.  For now, we are
making the code not crash, with an in efficient `dq -> index -> q`
implementation.  A future PR can optimize performance by removing
the unnecessary memory copies (which will require some non-trivial
changes to TensorIterator).

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 7591b5f90438a20fc92b962887092834e220c14a
Pull Request resolved: #49346
facebook-github-bot pushed a commit that referenced this pull request Dec 16, 2020
#49346)

Summary:
Pull Request resolved: #49346

This is less ambitious redo of
#49129.

We make the

```
xq_slice = xq[:, [0], :, :]
```

indexing syntax work if `xq` is a quantized Tensor.  For now, we are
making the code not crash, with an in efficient `dq -> index -> q`
implementation.  A future PR can optimize performance by removing
the unnecessary memory copies (which will require some non-trivial
changes to TensorIterator).

Test Plan:
```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Imported from OSS

Reviewed By: jerryzh168

Differential Revision: D25539365

fbshipit-source-id: 98485875aaaf5743e1a940e170258057691be4fa
@vkuzo
Copy link
Contributor Author

vkuzo commented Dec 28, 2020

thanks for the review! We went with a simpler and less performant approach of using the fp32 kernel for now in #49346, we might revisit supporting this natively in the future.

@vkuzo vkuzo closed this Dec 28, 2020
hwangdeyu pushed a commit to hwangdeyu/pytorch that referenced this pull request Jan 6, 2021
pytorch#49346)

Summary:
Pull Request resolved: pytorch#49346

This is less ambitious redo of
pytorch#49129.

We make the

```
xq_slice = xq[:, [0], :, :]
```

indexing syntax work if `xq` is a quantized Tensor.  For now, we are
making the code not crash, with an in efficient `dq -> index -> q`
implementation.  A future PR can optimize performance by removing
the unnecessary memory copies (which will require some non-trivial
changes to TensorIterator).

Test Plan:
```
python test/test_quantization.py TestQuantizedOps.test_advanced_indexing
```

Imported from OSS

Reviewed By: jerryzh168

Differential Revision: D25539365

fbshipit-source-id: 98485875aaaf5743e1a940e170258057691be4fa
@facebook-github-bot facebook-github-bot deleted the gh/vkuzo/184/head branch January 27, 2021 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants