Skip to content

Improve single element tensor handling - #3302

Merged
copybara-service[bot] merged 1 commit into
mainfrom
mdgrs/singleElementTensors
Aug 6, 2026
Merged

Improve single element tensor handling#3302
copybara-service[bot] merged 1 commit into
mainfrom
mdgrs/singleElementTensors

Conversation

@mdgrs

@mdgrs mdgrs commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@mdgrs
mdgrs requested a review from j2kun August 5, 2026 12:21
// once and splat it instead.
if (dataSemanticType && dataSemanticType.hasStaticShape() &&
dataSemanticType.getNumElements() == 1 &&
isDenseLayout(rel, targetType)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i think isDenseLayout takes some time and there's a small chance that it can both run up on line 374 and here - I think in the case that it's a splat tensor of some Value (not constant) with size one.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point. I folded this if into the preceding one, to avoid this

fold single element tensor in existing if
@mdgrs
mdgrs force-pushed the mdgrs/singleElementTensors branch from b07076a to 7c361bc Compare August 5, 2026 14:50
@j2kun j2kun added the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label Aug 6, 2026
@copybara-service
copybara-service Bot merged commit 58a2b2d into main Aug 6, 2026
22 checks passed
@copybara-service
copybara-service Bot deleted the mdgrs/singleElementTensors branch August 6, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants