-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix batch matching for batch mat mul #7062
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a nit related to modulus. Thanks!
a3dValues[batchIndexA * aBatch + i * aOuterStep + k * aInnerStep]; | ||
const bVal = | ||
b3dValues[k * bInnerStep + j * bOuterStep + batchOffsetB]; | ||
// tslint:disable-next-line: max-line-length | ||
b3dValues[k * bInnerStep + j * bOuterStep + batchIndexB * bBatch]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering why k
matched with aInnerStep
but did not then match with bOuterStep
, but I see now that bOuterStep
and bInnerStep
are opposite to aOuterStep
and aInnerStep
(lines 82 - 87). They don't refer to 'rows' and 'columns' of the matrices being multiplied, where you would step a
's row index with b
's column index for the dot product.
No action necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, we can move the batch variable assignment up to the loop of bi
, given those assignment only depends on the bi
value not other loop variables. It can be a separate PR.
Reviewable status:
complete! 2 of 1 approvals obtained (waiting on @Linchenn and @mattsoulanille)
BUG * fix * lint * fix
Fix #7061 for CPU, WASM (native implementation) and WebGL backends.
This error is because of batch mismatch when A has more dimensions than B, and vice versa.
For example: A's shape is
[2,4,3,3]
and B's shape is[4,3,3]
. Then A's batch is the first two dimensions[2, 4]
while B's batch is the first dimension[4]
, so B's batch is supposed to be broadcasted to be[2, 4]
. Then, to computeoutput[1][0][0][0]
, we have to do dot product ofA[1][0] [0][...]
withB[0] [...][0]
, but the current algorithm is doing dot product ofA[1][0][0][...]
withB[3][...][0]
.To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.
This change is