| 31 | namespace { |
| 32 | |
| 33 | TEST(LstmTest, Input2x2x1) { |
| 34 | TensorRef<BHWC> input; |
| 35 | input.type = DataType::FLOAT32; |
| 36 | input.ref = 0; |
| 37 | input.shape = BHWC(1, 2, 2, 1); |
| 38 | |
| 39 | TensorRef<BHWC> prev_state; |
| 40 | prev_state.type = DataType::FLOAT32; |
| 41 | prev_state.ref = 1; |
| 42 | prev_state.shape = BHWC(1, 2, 2, 1); |
| 43 | |
| 44 | TensorRef<BHWC> output_state; |
| 45 | output_state.type = DataType::FLOAT32; |
| 46 | output_state.ref = 2; |
| 47 | output_state.shape = BHWC(1, 2, 2, 1); |
| 48 | |
| 49 | TensorRef<BHWC> output_activation; |
| 50 | output_activation.type = DataType::FLOAT32; |
| 51 | output_activation.ref = 3; |
| 52 | output_activation.shape = BHWC(1, 2, 2, 1); |
| 53 | |
| 54 | LstmAttributes attr; |
| 55 | attr.kernel_type = LstmKernelType::BASIC; |
| 56 | |
| 57 | SingleOpModel model({ToString(OperationType::LSTM), attr}, |
| 58 | {input, prev_state}, {output_state, output_activation}); |
| 59 | ASSERT_TRUE(model.PopulateTensor(0, {1, 2, 3, 4})); |
| 60 | ASSERT_TRUE(model.PopulateTensor(1, {5, 6, 7, 8})); |
| 61 | ASSERT_OK(model.Invoke(*NewLstmNodeShader())); |
| 62 | EXPECT_THAT(model.GetOutput(0), |
| 63 | Pointwise(FloatNear(1e-6), {2.5, 3.0, 3.5, 4.0})); |
| 64 | EXPECT_THAT( |
| 65 | model.GetOutput(1), |
| 66 | Pointwise(FloatNear(1e-6), {0.493307, 0.497527, 0.499089, 0.499665})); |
| 67 | } |
| 68 | |
| 69 | } // namespace |
| 70 | } // namespace gl |
nothing calls this directly
no test coverage detected