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.
Avoid treating the tensor on the device as a CPU scalar tensor. syncStream will be called internally by tensor.item(), which is costly. If the tensor on the CPU has only one element and its shape is not empty, such as [1], [1,1], [1,1,...], it should be treated as a Scalar and the corresponding kernel function should be called. There are places in core where a scalar is wrapped but not marked as wrapped.
see https://github.com/pytorch/pytorch/blob/8f70bf7a943799b5cd870952d39f36361de4b87f/torch/csrc/lazy/core/tensor.cpp#L386