[Zero-Dim] fix Tensor.numpy, control whether to hack process to 1D #51757
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
Bug fixes
PR changes
APIs
Describe
Tensor.numpy()的hack为1D的处理,由于框架内部某些API调用了Tensor.numpy(),该hack处理会扩散到框架其他的API,导致一些其他错误的出现,因此增加了一个set_to_1d参数控制是否hack处理,默认下:
Tensor.numpy()
会将0D hack处理为1D;Tensor.numpy(False)
则没有该hack操作;注意:这部分的hack代码仅保持一定版本,后续下个大版本,会移除这些全部hack代码。