Skip to content

Conversation

@titaiwangms
Copy link
Contributor

@titaiwangms titaiwangms commented Oct 28, 2024

From #1916, it is found that the undefined shape disables the functionality of IsScalar op:

This PR annotates python scalar to be 0d tensor.

@titaiwangms titaiwangms added the module: torchlib Related to the torch/aten function lib in development label Oct 28, 2024
@codecov
Copy link

codecov bot commented Oct 28, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 75.49%. Comparing base (561a600) to head (cdaf733).

Files with missing lines Patch % Lines
onnxscript/function_libs/torch_lib/ops/core.py 50.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1918      +/-   ##
==========================================
- Coverage   75.49%   75.49%   -0.01%     
==========================================
  Files         252      252              
  Lines       27346    27355       +9     
  Branches     3172     3176       +4     
==========================================
+ Hits        20645    20651       +6     
  Misses       5740     5740              
- Partials      961      964       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

start = op.Reshape(start, op.Constant(value_ints=[-1]))
length = op.Reshape(length, op.Constant(value_ints=[-1]))
if IsScalar(dim):
dim = op.Reshape(dim, op.Constant(value_ints=[-1]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest changing the -1 to 1 ... since it is going to have the shape [1]. Ensures better shape inference with all of the various shape-inference implementations around.

dim = op.Reshape(dim, op.Constant(value_ints=[-1]))

if IsScalar(start):
start = op.Reshape(start, op.Constant(value_ints=[-1]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above, here and below

attributes=dict(value=constant_tensor),
)[0]
value.setDebugName(_rename_intermediate_value(value.debugName()))
if shape is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest not touching this file as it is deprecated.

Copy link
Collaborator

@justinchuby justinchuby left a comment

Choose a reason for hiding this comment

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

I would suggest doing this differently. The shape info may not be needed?

@titaiwangms
Copy link
Contributor Author

I would suggest doing this differently. The shape info may not be needed?

This may be low priority. It all starts #1916 that I re-wrote aten_narrow to adapt the change that I moved YracedONNXFunction to promote python constants to tensors before function call. With doing that, IsScalar loses its functionnality because we didn't assign shape to tensors. That's why I create this PR.

@titaiwangms
Copy link
Contributor Author

Leave it as it is for now. For torchlib, we keep the implementation, and CI tests will be deprecated soon with OpSignature PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: torchlib Related to the torch/aten function lib in development

Projects

Development

Successfully merging this pull request may close these issues.

3 participants