Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 1 | // Copyright 2019 Google LLC |
| 2 | // |
| 3 | // This source code is licensed under the BSD-style license found in the |
| 4 | // LICENSE file in the root directory of this source tree. |
| 5 | |
| 6 | #include <gtest/gtest.h> |
| 7 | |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 8 | #include "binary-elementwise-operator-tester.h" |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 9 | |
| 10 | |
Marat Dukhan | efc47b8 | 2019-11-18 09:25:38 -0800 | [diff] [blame] | 11 | TEST(MULTIPLY_ND_F32, vector_x_vector) { |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 12 | BinaryElementwiseOperatorTester() |
| 13 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 14 | .input1_shape({2}) |
| 15 | .input2_shape({2}) |
| 16 | .iterations(1) |
| 17 | .TestF32(); |
| 18 | } |
| 19 | |
Marat Dukhan | efc47b8 | 2019-11-18 09:25:38 -0800 | [diff] [blame] | 20 | TEST(MULTIPLY_ND_F32, vector_x_scalar) { |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 21 | BinaryElementwiseOperatorTester() |
| 22 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 23 | .input1_shape({2}) |
| 24 | .iterations(1) |
| 25 | .TestF32(); |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 26 | BinaryElementwiseOperatorTester() |
| 27 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 28 | .input1_shape({2}) |
| 29 | .input2_shape({1}) |
| 30 | .iterations(1) |
| 31 | .TestF32(); |
| 32 | } |
| 33 | |
Marat Dukhan | efc47b8 | 2019-11-18 09:25:38 -0800 | [diff] [blame] | 34 | TEST(MULTIPLY_ND_F32, scalar_x_vector) { |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 35 | BinaryElementwiseOperatorTester() |
| 36 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 37 | .input2_shape({2}) |
| 38 | .iterations(1) |
| 39 | .TestF32(); |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 40 | BinaryElementwiseOperatorTester() |
| 41 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 42 | .input1_shape({1}) |
| 43 | .input2_shape({2}) |
| 44 | .iterations(1) |
| 45 | .TestF32(); |
| 46 | } |
| 47 | |
Marat Dukhan | efc47b8 | 2019-11-18 09:25:38 -0800 | [diff] [blame] | 48 | TEST(MULTIPLY_ND_F32, matrix_x_matrix) { |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 49 | BinaryElementwiseOperatorTester() |
| 50 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 51 | .input1_shape({2, 3}) |
| 52 | .input2_shape({2, 3}) |
| 53 | .iterations(1) |
| 54 | .TestF32(); |
| 55 | } |
| 56 | |
Marat Dukhan | efc47b8 | 2019-11-18 09:25:38 -0800 | [diff] [blame] | 57 | TEST(MULTIPLY_ND_F32, matrix_x_row) { |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 58 | BinaryElementwiseOperatorTester() |
| 59 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 60 | .input1_shape({2, 3}) |
| 61 | .input2_shape({1, 3}) |
| 62 | .iterations(1) |
| 63 | .TestF32(); |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 64 | BinaryElementwiseOperatorTester() |
| 65 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 66 | .input1_shape({2, 3}) |
| 67 | .input2_shape({3}) |
| 68 | .iterations(1) |
| 69 | .TestF32(); |
| 70 | } |
| 71 | |
Marat Dukhan | efc47b8 | 2019-11-18 09:25:38 -0800 | [diff] [blame] | 72 | TEST(MULTIPLY_ND_F32, matrix_x_column) { |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 73 | BinaryElementwiseOperatorTester() |
| 74 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 75 | .input1_shape({2, 3}) |
| 76 | .input2_shape({2, 1}) |
| 77 | .iterations(1) |
| 78 | .TestF32(); |
| 79 | } |
| 80 | |
Marat Dukhan | efc47b8 | 2019-11-18 09:25:38 -0800 | [diff] [blame] | 81 | TEST(MULTIPLY_ND_F32, matrix_x_scalar) { |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 82 | BinaryElementwiseOperatorTester() |
| 83 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 84 | .input1_shape({2, 3}) |
| 85 | .input2_shape({1, 1}) |
| 86 | .iterations(1) |
| 87 | .TestF32(); |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 88 | BinaryElementwiseOperatorTester() |
| 89 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 90 | .input1_shape({2, 3}) |
| 91 | .input2_shape({1}) |
| 92 | .iterations(1) |
| 93 | .TestF32(); |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 94 | BinaryElementwiseOperatorTester() |
| 95 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 96 | .input1_shape({2, 3}) |
| 97 | .iterations(1) |
| 98 | .TestF32(); |
| 99 | } |
| 100 | |
Marat Dukhan | efc47b8 | 2019-11-18 09:25:38 -0800 | [diff] [blame] | 101 | TEST(MULTIPLY_ND_F32, row_x_matrix) { |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 102 | BinaryElementwiseOperatorTester() |
| 103 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 104 | .input1_shape({1, 3}) |
| 105 | .input2_shape({2, 3}) |
| 106 | .iterations(1) |
| 107 | .TestF32(); |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 108 | BinaryElementwiseOperatorTester() |
| 109 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 110 | .input1_shape({3}) |
| 111 | .input2_shape({2, 3}) |
| 112 | .iterations(1) |
| 113 | .TestF32(); |
| 114 | } |
| 115 | |
Marat Dukhan | efc47b8 | 2019-11-18 09:25:38 -0800 | [diff] [blame] | 116 | TEST(MULTIPLY_ND_F32, column_x_matrix) { |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 117 | BinaryElementwiseOperatorTester() |
| 118 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 119 | .input1_shape({2, 1}) |
| 120 | .input2_shape({2, 3}) |
| 121 | .iterations(1) |
| 122 | .TestF32(); |
| 123 | } |
| 124 | |
Marat Dukhan | efc47b8 | 2019-11-18 09:25:38 -0800 | [diff] [blame] | 125 | TEST(MULTIPLY_ND_F32, scalar_x_matrix) { |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 126 | BinaryElementwiseOperatorTester() |
| 127 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 128 | .input1_shape({1, 1}) |
| 129 | .input2_shape({2, 3}) |
| 130 | .iterations(1) |
| 131 | .TestF32(); |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 132 | BinaryElementwiseOperatorTester() |
| 133 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 134 | .input1_shape({1}) |
| 135 | .input2_shape({2, 3}) |
| 136 | .iterations(1) |
| 137 | .TestF32(); |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame^] | 138 | BinaryElementwiseOperatorTester() |
| 139 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Multiply) |
Marat Dukhan | ca2733c | 2019-11-15 23:21:17 -0800 | [diff] [blame] | 140 | .input2_shape({2, 3}) |
| 141 | .iterations(1) |
| 142 | .TestF32(); |
| 143 | } |