| 38 | // ---------------------------------------------------------------------------------------- |
| 39 | |
| 40 | void test_onnx_export() |
| 41 | { |
| 42 | print_spinner(); |
| 43 | |
| 44 | { |
| 45 | using net_type = loss_multiclass_log<fc<2,relu<max_pool<2,2,2,2,con<3,3,3,1,1,input_tensor>>>>>; |
| 46 | net_type net; |
| 47 | onnx_export_options options; |
| 48 | options.input_tensor_shape = {1, 3, 8, 8}; |
| 49 | options.input_name = "data"; |
| 50 | options.output_name = "scores"; |
| 51 | |
| 52 | std::ostringstream sout(std::ios::binary); |
| 53 | net_to_onnx(net, sout, options); |
| 54 | const std::string model = sout.str(); |
| 55 | |
| 56 | DLIB_TEST_MSG(!model.empty(), "empty ONNX export"); |
| 57 | DLIB_TEST(contains_substring(model, "dlib")); |
| 58 | DLIB_TEST(contains_substring(model, "Conv")); |
| 59 | DLIB_TEST(contains_substring(model, "MaxPool")); |
| 60 | DLIB_TEST(contains_substring(model, "Relu")); |
| 61 | DLIB_TEST(contains_substring(model, "Gemm")); |
| 62 | DLIB_TEST(contains_substring(model, "data")); |
| 63 | DLIB_TEST(contains_substring(model, "scores")); |
| 64 | } |
| 65 | |
| 66 | { |
| 67 | using net_type = loss_multiclass_log<fc<2,input_rgb_image_sized<8,8>>>; |
| 68 | net_type net; |
| 69 | onnx_export_options options; |
| 70 | |
| 71 | std::ostringstream sout(std::ios::binary); |
| 72 | net_to_onnx(net, sout, options); |
| 73 | const std::string model = sout.str(); |
| 74 | |
| 75 | DLIB_TEST(contains_substring(model, "Gemm")); |
| 76 | DLIB_TEST(contains_substring(model, "input")); |
| 77 | DLIB_TEST(contains_substring(model, "output")); |
| 78 | } |
| 79 | |
| 80 | { |
| 81 | using a1 = sig<input_tensor>; |
| 82 | using a2 = htan<a1>; |
| 83 | using a3 = leaky_relu<a2>; |
| 84 | using a4 = prelu<a3>; |
| 85 | using a5 = clipped_relu<a4>; |
| 86 | using a6 = elu<a5>; |
| 87 | using a7 = gelu<a6>; |
| 88 | using a8 = silu<a7>; |
| 89 | using a9 = mish<a8>; |
| 90 | using net_type = loss_multiclass_log<fc<2,a9>>; |
| 91 | net_type net; |
| 92 | onnx_export_options options; |
| 93 | options.input_tensor_shape = {1, 3, 4, 4}; |
| 94 | |
| 95 | std::ostringstream sout(std::ios::binary); |
| 96 | net_to_onnx(net, sout, options); |
| 97 | const std::string model = sout.str(); |
no test coverage detected