Skip to content
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

Unary broadcast lowering #995

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KavithaTipturMadhu
Copy link
Contributor

@KavithaTipturMadhu KavithaTipturMadhu commented Dec 11, 2024

No description provided.

@KavithaTipturMadhu KavithaTipturMadhu force-pushed the broadcast branch 2 times, most recently from 630ce39 to 12cf5a1 Compare December 12, 2024 10:41
@KavithaTipturMadhu KavithaTipturMadhu marked this pull request as ready for review December 12, 2024 10:48
Copy link
Contributor

@rengolin rengolin left a comment

Choose a reason for hiding this comment

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

You have huge gaps in your testing. You need to make sure the tests are correct (I'm not so sure about that), that they follow the path you expect (linalg-to-vector and vector-to-xsmm), and that the output is correct.

You did some of those things for different integration tests. You need to do all of those things for all integration tests. You also need negative conversion tests (dims that don't match, reducing rank, etc), and a more comprehensive functionality testing (more patterns like 1D to 2D, 2D to 3D, 1D to 3D, etc).

It would also be interesting to have a more elaborate test, where you start adding all of the supported patterns. For now, one that has a transpose followed by a broadcast and another that is the other way round. You should match both patterns on both cases, and create two function calls on both.

include/TPP/Dialect/Xsmm/XsmmUtils.h Outdated Show resolved Hide resolved
lib/TPP/DefaultTppPasses.cpp Show resolved Hide resolved
#map2 = affine_map<(d0, d1, d2) -> (d2)>
#map3 = affine_map<(d0, d1, d2) -> (d0, d1, d2)>

func.func @columnBroadcast(%arg0: tensor<8xf32>, %arg1: tensor<2x4x8xf32>) -> tensor<2x4x8xf32> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really a 2D column broadcast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a column broadcast, which is what the function is called, the file should probably be renamed broadcast with 2D destination or something, can you please suggest an appropriate name for the test file?

test/Integration/broadcast-2d.mlir Show resolved Hide resolved
test/Integration/broadcast-row.mlir Show resolved Hide resolved
@adam-smnk
Copy link
Collaborator

+1 on more test coverage or rather more specific matchers
Our tests right now surely don't cover all vector.broadcast semantics.

As an example:

func.func @entry(%arg0: memref<4x1xf32>, %arg1: memref<4x2xf32>) -> memref<4x2xf32> {
  %c0 = arith.constant 0 : index
  %cst = arith.constant 0.000000e+00 : f32
  %0 = vector.transfer_read %arg0[%c0, %c0], %cst {in_bounds = [true, true]} : memref<4x1xf32>, vector<4x1xf32>
  %1 = vector.broadcast %0 : vector<4x1xf32> to vector<4x2xf32>
  vector.transfer_write %1, %arg1[%c0, %c0] {in_bounds = [true, true]}
    : vector<4x2xf32>, memref<4x2xf32>
  return %arg1 : memref<4x2xf32>
}

This broadcast fails at runtime xsmm JIT step. I'm sure we don't need this variant currently but it'd be best not to open ourselves to new pitfalls.

@adam-smnk
Copy link
Collaborator

As a side note, it could be that our current lowering from linalg is also incomplete. I don't want to feature/scope creep this PR.
Let's just agree on some sufficient state and possibly note down future necessary improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants