| 31 | namespace { |
| 32 | |
| 33 | TEST(AddTest, TwoInputTensorsOfTheSameShape) { |
| 34 | TensorRef<BHWC> augend, addend, output; |
| 35 | augend.type = DataType::FLOAT32; |
| 36 | augend.ref = 0; |
| 37 | augend.shape = BHWC(1, 2, 2, 1); |
| 38 | |
| 39 | addend.type = DataType::FLOAT32; |
| 40 | addend.ref = 1; |
| 41 | addend.shape = BHWC(1, 2, 2, 1); |
| 42 | |
| 43 | output.type = DataType::FLOAT32; |
| 44 | output.ref = 2; |
| 45 | output.shape = BHWC(1, 2, 2, 1); |
| 46 | |
| 47 | AddAttributes attr; |
| 48 | SingleOpModel model({ToString(OperationType::ADD), std::move(attr)}, |
| 49 | {augend, addend}, {output}); |
| 50 | ASSERT_TRUE(model.PopulateTensor(0, {-2.0, 0.2, 0.7, 0.8})); |
| 51 | ASSERT_TRUE(model.PopulateTensor(1, {0.1, 0.2, 0.3, 0.5})); |
| 52 | ASSERT_OK(model.Invoke(*NewAddNodeShader())); |
| 53 | EXPECT_THAT(model.GetOutput(0), |
| 54 | Pointwise(FloatNear(1e-6), {-1.9, 0.4, 1.0, 1.3})); |
| 55 | } |
| 56 | |
| 57 | TEST(AddTest, InputTensorAndScalar) { |
| 58 | AddAttributes attr; |
nothing calls this directly
no test coverage detected