| 16 | } |
| 17 | |
| 18 | void RNNCell::check_exec( |
| 19 | const TensorLayout& input, const TensorLayout& weight_ih, |
| 20 | const TensorLayout& bias_ih, const TensorLayout& hx, |
| 21 | const TensorLayout& weight_hh, const TensorLayout& bias_hh, |
| 22 | const TensorLayout& dst, size_t workspace_in_bytes) { |
| 23 | TensorLayout dst_expected; |
| 24 | auto errmsg = [&]() { |
| 25 | std::string msg; |
| 26 | msg.append("input="); |
| 27 | msg.append(input.to_string()); |
| 28 | msg.append(", weight_ih="); |
| 29 | msg.append(weight_ih.to_string()); |
| 30 | msg.append(", bias_ih="); |
| 31 | msg.append(bias_ih.to_string()); |
| 32 | msg.append(", hx="); |
| 33 | msg.append(hx.to_string()); |
| 34 | msg.append(", weight_hh="); |
| 35 | msg.append(weight_hh.to_string()); |
| 36 | msg.append(", bias_hh="); |
| 37 | msg.append(bias_hh.to_string()); |
| 38 | msg.append(", dst="); |
| 39 | msg.append(dst.to_string()); |
| 40 | return msg; |
| 41 | }; |
| 42 | #define ASSERT_BRIEF(_content) megdnn_assert(_content, "%s", errmsg().c_str()); |
| 43 | |
| 44 | ASSERT_BRIEF(input.ndim == 2) |
| 45 | ASSERT_BRIEF(hx.ndim == 2) |
| 46 | ASSERT_BRIEF(hx.shape[0] == input.shape[0]) // batch |
| 47 | ASSERT_BRIEF(input.shape[1] == weight_ih.shape[1]) |
| 48 | ASSERT_BRIEF(hx.shape[0] == dst.shape[0]) // batch |
| 49 | ASSERT_BRIEF(hx.shape[1] == dst.shape[1]) |
| 50 | ASSERT_BRIEF(hx.shape[1] == weight_ih.shape[0]) // hidden_size |
| 51 | ASSERT_BRIEF(weight_ih.shape[0] == weight_hh.shape[0]) |
| 52 | ASSERT_BRIEF(weight_hh.shape[0] == weight_hh.shape[1]) |
| 53 | ASSERT_BRIEF(bias_ih.shape[0] == bias_hh.shape[0]) |
| 54 | #undef ASSERT_BRIEF |
| 55 | megdnn_assert_eq_dtype(input, dst); |
| 56 | megdnn_assert_eq_dtype(hx, dst); |
| 57 | deduce_layout(input, weight_ih, bias_ih, hx, weight_hh, bias_hh, dst_expected); |
| 58 | megdnn_assert_eq_layout(dst_expected, dst); |
| 59 | |
| 60 | auto required_workspace_in_bytes = get_workspace_in_bytes( |
| 61 | input, weight_ih, bias_ih, hx, weight_hh, bias_hh, dst); |
| 62 | megdnn_assert(workspace_in_bytes >= required_workspace_in_bytes); |
| 63 | } |
| 64 | |
| 65 | } // namespace megdnn |
| 66 |
nothing calls this directly
no test coverage detected