| 7 | namespace test { |
| 8 | |
| 9 | TEST_F(NAIVE, RNN_FORWARD) { |
| 10 | Checker<RNN> checker(handle(), false); |
| 11 | size_t batch_size = 2; |
| 12 | size_t input_size = 3; |
| 13 | size_t hidden_size = 2; |
| 14 | size_t seq_len = 2; |
| 15 | size_t gate_hidden_size = hidden_size; |
| 16 | RNN::Param param; |
| 17 | param.num_layers = 1; |
| 18 | param.bidirectional = false; |
| 19 | param.bias = false; |
| 20 | param.hidden_size = hidden_size; |
| 21 | param.nonlineMode = param::RNN::NonlineMode::RELU; |
| 22 | checker.set_param(param).exect( |
| 23 | Testcase{ |
| 24 | TensorValue( |
| 25 | {seq_len, batch_size, input_size}, dtype::Float32(), |
| 26 | {-0.66536, 0.08049, 0.12008, 0.63423, 1.37801, 0.02591, |
| 27 | 0.09153, 0.82866, -1.70429, -1.26624, -0.06421, |
| 28 | 0.35816}), // input |
| 29 | TensorValue( |
| 30 | {batch_size, hidden_size}, dtype::Float32(), |
| 31 | {-3.19544, -1.24232, 1.99512, -0.25692}), // hx |
| 32 | TensorValue( |
| 33 | {gate_hidden_size, input_size + hidden_size}, |
| 34 | dtype::Float32(), |
| 35 | {0.35355, 0.35355, 0.35355, 0.35355, 0.35355, 0.35355, |
| 36 | 0.35355, 0.35355, 0.35355, 0.35355}), // flattern weights |
| 37 | {}, |
| 38 | {}, |
| 39 | {}}, |
| 40 | Testcase{ |
| 41 | {}, |
| 42 | {}, |
| 43 | {}, |
| 44 | TensorValue( |
| 45 | {seq_len, batch_size, hidden_size}, dtype::Float32(), |
| 46 | {0.0, 0.0, 1.3351, 1.3351, 0.0, 0.0, 0.6003, |
| 47 | 0.6003}), // output |
| 48 | TensorValue( |
| 49 | {batch_size, hidden_size}, dtype::Float32(), |
| 50 | {0.0, 0.0, 0.6003, 0.6003}), // hy |
| 51 | TensorValue( |
| 52 | {1, 2, 2, 2}, dtype::Float32(), |
| 53 | {0.0, 0.0, 1.33512, 1.33512, 0.0, 0.0, 0.60031, |
| 54 | 0.60031}) // reserve space |
| 55 | }); |
| 56 | param.num_layers = 2; |
| 57 | checker.set_param(param).exect( |
| 58 | Testcase{ |
| 59 | TensorValue( |
| 60 | {seq_len, batch_size, input_size}, dtype::Float32(), |
| 61 | {-0.66536, 0.08049, 0.12008, 0.63423, 1.37801, 0.02591, |
| 62 | 0.09153, 0.82866, -1.70429, -1.26624, -0.06421, |
| 63 | 0.35816}), // input |
| 64 | TensorValue( |
| 65 | {2, batch_size, hidden_size}, dtype::Float32(), |
| 66 | {-3.19544, -1.24232, 1.99512, -0.25692, -3.19544, -1.24232, |
nothing calls this directly
no test coverage detected