-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[quant] Add dequantize.tensors #34348
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
Changes from all commits
d1147d7
74d5bf4
a9084ff
9921674
7587dd6
5ea41d6
78c3abc
f3da80e
45f7d4f
d092b5f
5151729
78d6231
1eb83d7
ec3541c
9b3eb77
c381bb5
9a93036
c1eaaed
8a6d2a6
971cd89
7285268
793d02b
11ae851
3098c87
053898f
8f768ff
e73f1d0
f4696de
d60b690
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,14 @@ Tensor dequantize_quant(const Tensor& self) { | |
| return get_qtensorimpl(self)->quantizer()->dequantize(self); | ||
| } | ||
|
|
||
| std::vector<Tensor> dequantize_tensors_quant(TensorList tensors) { | ||
jerryzh168 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't return a std::vector, return a TensorList instead (TensorList == torch::List). std::vector requires a copy behind the scenes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that is not the type generated by native_functions.yaml, I looked up another function that returns Tensor[] and it says: |
||
| std::vector<Tensor> dequantized_tensors; | ||
| for (auto i = 0; i < tensors.size(); ++i) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use parallel for here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would delay this optimization until there is a need, most likely this function will never be run since it will be fused into the quantized::cat pattern. |
||
| dequantized_tensors.push_back(tensors[i].dequantize()); | ||
| } | ||
| return dequantized_tensors; | ||
| } | ||
|
|
||
| double q_scale_quant(const Tensor& self) { | ||
| auto quantizer = get_qtensorimpl(self)->quantizer(); | ||
| TORCH_CHECK(quantizer->qscheme() == kPerTensorAffine); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,6 +92,7 @@ | |
| 'div_', | ||
| 'div_out', | ||
| 'floor_divide', 'floor_divide_', 'floor_divide_out', | ||
| 'dequantize', | ||
| ] | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is ListConstruct special? What about other structures like Tuple or Dict of tensors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll need to handle those as well if they come up in real use cases, but by far I didn't see that. Reason we have lists are mostly because we have quantized ops like cat that takes list as input. if we have quantized ops that takes Dict or Tuple as inputs we'll probably need to add support for these other types as well