| 30 | } |
| 31 | |
| 32 | TEST(math_function, gemm_notrans_cblas) { |
| 33 | phi::DenseTensor input1; |
| 34 | phi::DenseTensor input2; |
| 35 | phi::DenseTensor input3; |
| 36 | |
| 37 | int m = 2; |
| 38 | int n = 3; |
| 39 | int k = 3; |
| 40 | auto* dev_ctx = |
| 41 | phi::DeviceContextPool::Instance().GetByPlace(phi::CPUPlace()); |
| 42 | |
| 43 | input1.Resize({2, 3}); |
| 44 | float* input1_ptr = dev_ctx->template Alloc<float>(&input1); |
| 45 | std::array<float, 6> arr1 = {0, 1, 2, 3, 4, 5}; |
| 46 | memcpy(input1_ptr, arr1.data(), 6 * sizeof(float)); |
| 47 | input2.Resize({3, 4}); |
| 48 | float* input2_ptr = dev_ctx->template Alloc<float>(&input2); |
| 49 | std::array<float, 12> arr2 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; |
| 50 | memcpy(input2_ptr, arr2.data(), 12 * sizeof(float)); |
| 51 | input3.Resize({2, 4}); |
| 52 | float* input3_ptr = dev_ctx->template Alloc<float>(&input3); |
| 53 | std::array<float, 8> arr3 = {0, 1, 2, 3, 4, 5, 6, 7}; |
| 54 | memcpy(input3_ptr, arr3.data(), 8 * sizeof(float)); |
| 55 | |
| 56 | GetBlas<float>(*dev_ctx).GEMM(false, |
| 57 | false, |
| 58 | m, |
| 59 | n, |
| 60 | k, |
| 61 | 1, |
| 62 | input1_ptr, |
| 63 | 3, |
| 64 | input2_ptr + 1, |
| 65 | 4, |
| 66 | 1, |
| 67 | input3_ptr + 1, |
| 68 | 4); |
| 69 | |
| 70 | EXPECT_EQ(input3_ptr[0], 0); |
| 71 | EXPECT_EQ(input3_ptr[1], 24); |
| 72 | EXPECT_EQ(input3_ptr[2], 28); |
| 73 | EXPECT_EQ(input3_ptr[3], 32); |
| 74 | EXPECT_EQ(input3_ptr[4], 4); |
| 75 | EXPECT_EQ(input3_ptr[5], 73); |
| 76 | EXPECT_EQ(input3_ptr[6], 86); |
| 77 | EXPECT_EQ(input3_ptr[7], 99); |
| 78 | } |
| 79 | #ifdef PADDLE_WITH_LIBXSMM |
| 80 | template <typename T> |
| 81 | void MklSmmCompare(int m, int n, int k) { |
nothing calls this directly
no test coverage detected