| 29 | namespace { |
| 30 | |
| 31 | TEST(PReluTest, LinearAlphaNoClip) { |
| 32 | TensorRef<BHWC> input; |
| 33 | input.type = DataType::FLOAT32; |
| 34 | input.ref = 0; |
| 35 | input.shape = BHWC(1, 2, 2, 1); |
| 36 | |
| 37 | PReLUAttributes attr; |
| 38 | attr.clip = 0; |
| 39 | Tensor<Linear, DataType::FLOAT32> alpha; |
| 40 | alpha.shape.v = 1; |
| 41 | alpha.id = 1; |
| 42 | alpha.data = {2}; |
| 43 | attr.alpha = std::move(alpha); |
| 44 | |
| 45 | TensorRef<BHWC> output; |
| 46 | output.type = DataType::FLOAT32; |
| 47 | output.ref = 2; |
| 48 | output.shape = BHWC(1, 2, 2, 1); |
| 49 | |
| 50 | SingleOpModel model({ToString(OperationType::PRELU), attr}, {input}, |
| 51 | {output}); |
| 52 | ASSERT_TRUE(model.PopulateTensor(0, {-1.0, -2.0, 1.0, 2.0})); |
| 53 | ASSERT_OK(model.Invoke(*NewPReLUNodeShader())); |
| 54 | EXPECT_THAT(model.GetOutput(0), Pointwise(FloatNear(1e-6), {-2, -4, 1, 2})); |
| 55 | } |
| 56 | |
| 57 | TEST(PReluTest, LinearAlphaWithClip) { |
| 58 | TensorRef<BHWC> input; |
no test coverage detected