Skip to content

Conversation

@Balint-R
Copy link
Collaborator

Rewrote much of the code for our existing linalg elementwise operations.

  • Removed making empty tensors for output operands, since a correct implementation of one-shot-bufferize should handle this fine.
  • Unary code mostly just got simplified, not much change in functionality.
  • Binary operations now accept 2 input arguments and an output argument, similar to MLIR.
    • The element types of the inputs are cast to the element type of the output by MLIR.
    • In the future, we should allow setting output to None and infer something reasonable for it.
  • Added tests for all binary linalg ops and fixed existing unary ones.

@Balint-R Balint-R force-pushed the linalg-update branch 2 times, most recently from 9f7e52b to a6d7eb0 Compare July 29, 2025 14:52
Copy link
Collaborator

@jamesthejellyfish jamesthejellyfish left a comment

Choose a reason for hiding this comment

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

seems like there was a small copying typo with your _gen_elementwise_binar_macro implementation. Other than that LGTM!

)

is_x_tensor = isinstance(x, Tensor)
is_y_tensor = isinstance(x, Tensor)
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this be isinstance(y, Tensor) and isinstance(out, Tensor)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops, yes you are correct. I even had a testcase for this, but it throws an error for a different reason. Maybe we should make errors with more specific types rather than throwing TypeError for almost anything...

@jamesthejellyfish jamesthejellyfish merged commit 99e5705 into Huawei-CPLLab:main Jul 29, 2025
1 check passed
@Balint-R Balint-R deleted the linalg-update branch July 29, 2025 18:48
@Balint-R Balint-R added the feature New feature or request label Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants