8000 Convenience function get_const_tensor by justinchuby · Pull Request #45 · onnx/ir-py · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Convenience function get_const_tensor #45

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

Merged
merged 14 commits into from
Jun 17, 2025
Merged

Conversation

justinchuby
Copy link
Member
@justinchuby justinchuby commented Jun 1, 2025

Get the constant tensor from a value, if it exists.

A constant tensor can be obtained if the value has a const_value set
(as in the case of an initializer) or if the value is produced by a
Constant node.

This function will not alter the const_value of the value, but
it will propagate the shape and type of the constant tensor to the value
if propagate_shape_type is set to True.

Copy link
codecov bot commented Jun 1, 2025

Codecov Report

Attention: Patch coverage is 69.23077% with 12 lines in your changes missing coverage. Please review.

Project coverage is 74.49%. Comparing base (26ca89a) to head (2bb6562).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/onnx_ir/_convenience/__init__.py 69.23% 6 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #45      +/-   ##
==========================================
- Coverage   74.51%   74.49%   -0.03%     
==========================================
  Files          37       37              
  Lines        4595     4634      +39     
  Branches      933      946      +13     
==========================================
+ Hits         3424     3452      +28     
- Misses        826      832       +6     
- Partials      345      350       +5     

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

@justinchuby
Copy link
Member Author

@codecov-ai-reviewer test

Copy link
Contributor
codecov-ai bot commented Jun 2, 2025

On it! Codecov is generating unit tests for this PR.

@codecov-ai codecov-ai bot mentioned this pull request Jun 2, 2025
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby justinchuby force-pushed the justinchu/constant-tensor branch from 898a6c6 to 4fec7af Compare June 3, 2025 15:58
@justinchuby justinchuby added this to the 0.1.2 milestone Jun 15, 2025
This PR adds tests for #45

### Commits:
- Add unit tests for get_constant_tensor function

This commit adds a new test file to validate the newly added
get_constant_tensor function.
The tests cover various scenarios including direct constant values,
values without producer nodes,
values with non-Constant producer nodes, and values produced by Constant
nodes with different
attribute types (float, int, tensor).

---------

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: codecov-ai[bot] <156709835+codecov-ai[bot]@users.noreply.github.com>
Copy link
Contributor
@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

lintrunner found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby justinchuby marked this pull request as ready for review June 16, 2025 23:24
@justinchuby justinchuby requested review from titaiwangms and a team as code owners June 16, 2025 23:24
@justinchuby justinchuby changed the title Convenience function get_constant_tensor Convenience function get_const_tensor Jun 16, 2025
8000 docs
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby
Copy link
Member Author

@titaiwangms

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Copy link
Collaborator
@titaiwangms titaiwangms left a comment

Choose a reason for hiding this comment

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

Unblocking nits and questions

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby justinchuby merged commit 2f48964 into main Jun 17, 2025
24 checks passed
@justinchuby justinchuby deleted the justinchu/constant-tensor branch June 17, 2025 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0