mlir-aie icon indicating copy to clipboard operation
mlir-aie copied to clipboard

matrix_multiplication_array produces incorrect result

Open Joel-De opened this issue 11 months ago • 1 comments

Hi,

The provided design seems to be incorrect. This can be verified by replacing the function static inline std::bfloat16_t random_bfloat16_t() in test.cpp with the following

static inline std::bfloat16_t random_bfloat16_t() {
  // generate random values between 0-15
  return (std::bfloat16_t)(rand() % 0x10);
}

and uncommenting the matmul() call in the verify section.

This change will subsequently fill the matrix A & B with random values (note that the prior implementation that was supposed to generate random values doesn't seem to be working, and only filled the vectors with a constant value of 0.0008 which is how I believe this bug snuck by). The current test of filling matrix A and B with 1 also doesn't highlight this issue since any errors with matrix offsets are masked by the homogeneity of the input matrices.

With these changes are made the already existing verification code will point out the mismatched values.

From the debugging I've done so far it appears that this is caused by an incorrect shift/index when tiling the larger mmul over multiple passes of the 16 tiles. Let me know if you're able to reproduce this issue on your end or if you see some issue with my test.

Joel-De avatar Mar 04 '24 02:03 Joel-De