[Zero-Dim] support input 0D Tensor for distribution transform api#47677
Merged
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
04e0d6e to
043ceae
Compare
043ceae to
098e654
Compare
cxxly
reviewed
Nov 8, 2022
| raise ValueError( | ||
| f"The numel of 'in_event_shape' should be 'out_event_shape', " | ||
| f"but got {functools.reduce(operator.mul, in_event_shape)}!={functools.reduce(operator.mul, out_event_shape)}" | ||
| f"but got {in_size}!={out_size}" |
Contributor
Author
There was a problem hiding this comment.
0D Tensor的shape为[],numel为1,用functools.reduce无法实现,会报空列表的错误,所以就自行实现了
cxxly
reviewed
Nov 8, 2022
| if shape[-len(self._in_event_shape) :] != self._in_event_shape: | ||
| if list(shape[-len(self._in_event_shape) :]) != list( | ||
| self._in_event_shape | ||
| ): |
cxxly
reviewed
Nov 8, 2022
| if list(shape[-len(self._out_event_shape) :]) != list( | ||
| self._out_event_shape | ||
| ): | ||
| raise ValueError( |
iclementine
reviewed
Nov 8, 2022
Comment on lines
+106
to
109
| # original patching object as well as re-constrfucted patches. | ||
| delete_patches_if_need(f) | ||
|
|
||
| f.__test__ = False |
iclementine
approved these changes
Nov 8, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR types
New features
PR changes
APIs
Describe
为Distribution Transform类API支持输入0D Tensor,如下: