Skip to content

Conversation

@V-FEXrt
Copy link
Collaborator

@V-FEXrt V-FEXrt commented Oct 22, 2025

dx.op.matrixOp was missing an opcode for Matrix Matrix Addition with Accumulation needed for Matrix::SumAccumulate.

This PR adds it to the spec

Three opcodes are available for this operation class:
* Matrix Matrix Multiply: `C = A * B`
* Matrix Matrix Multiply with Accumulation: `C += A * B`
* Matrix Matrix Addition with Accumulation: `C += A + B`
Copy link
Collaborator

Choose a reason for hiding this comment

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

When I look up for the operation class, I see it would be OpCodeClass::MatrixOp.

Isn't "MatrixOp" a little too generic? The operation is limited to accepting three matrix operands, where it overwrites or accumulates into the first one. On that note, I think the operation class should be all you need to know to reason about the type of memory accesses for each matrix, but they are different for multiply vs. multiply or add with accumulate.

I think I'd split this into MatrixBinaryOp and MatrixBinaryAccumulateOp.

What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't have any issues with that, but @llvm-beanz should confirm. Chris do you have any thoughts here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since you mentioned that you aren't blocking this PR I'll go ahead and merge as is but would love to keep the conversation going about the details here!

Further thoughts after chatting a bit with Chris:

Regardless of if we split these up or not they'll actually both end up with the same memory access annotations. MatrixBinaryOp would be readwrite* (read from A,B, write to C) and MatrixBinaryAccumulateOp would be readwrite* (read from A,B,C, write to C).

Also if we do split them, MatrixBinaryAccumulateOp should be called something like MatrixTernaryOp because its actually more of shape C' = A * B + C

*: I use readwrite but iirc the actual annotation is none/the empty string which implies readwrite

Copy link
Collaborator

@tex3d tex3d left a comment

Choose a reason for hiding this comment

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

I should clarify that my approval of this change isn't dependent on resolution of my comment about OpCodeClass::MatrixOp.

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants