#include <catch2/catch_all.hpp>
#include <Eigen/Core>
#include "sopt/ort_session.h"
#include "sopt/utilities.h"
#include "tools_for_tests/directories.h"
Go to the source code of this file.
|
| TEST_CASE ("Load an example ORT model", "[ONNXrt]") |
|
| TEST_CASE ("Check metadata of an example ORT model", "[ONNXrt]") |
|
| TEST_CASE ("Check forward folding of an example ORT model using std::vectors", "[ONNXrt]") |
|
| TEST_CASE ("Check forward folding of an example ORT model using sopt::Vectors", "[ONNXrt]") |
|
◆ TEST_CASE() [1/4]
TEST_CASE |
( |
"Check forward folding of an example ORT model using sopt::Vectors" |
, |
|
|
"" |
[ONNXrt] |
|
) |
| |
Definition at line 59 of file ort_model.cc.
62 ORTsession model(path+
"/example_grad_dynamic_CRR_sigma_5_t_5.onnx");
64 const size_t nROWS = 256, nCOLS = 256;
65 const size_t input_size = 1 * nROWS * nCOLS;
68 std::vector<float> input_values, expected_values;
69 input_values.reserve(input_size);
70 expected_values.reserve(input_size);
71 input_values = utilities::split<float>(model.retrieve<std::string>(
"x_init"),
",");
72 expected_values = utilities::split<float>(model.retrieve<std::string>(
"x_exp"),
",");
77 for (
size_t i = 0; i < input_values.size(); ++i) {
78 inputT[i] = input_values[i];
79 refT[i] = expected_values[i];
88 auto mse = (outputT - refT).squaredNorm() / outputT.size();
Sopt interface class to hold a ONNXrt session.
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector of a given type.
References sopt::ORTsession::compute(), sopt::tools::models_directory(), and sopt::ORTsession::retrieve().
◆ TEST_CASE() [2/4]
TEST_CASE |
( |
"Check forward folding of an example ORT model using std::vectors" |
, |
|
|
"" |
[ONNXrt] |
|
) |
| |
Definition at line 28 of file ort_model.cc.
31 ORTsession model(path+
"/example_grad_dynamic_CRR_sigma_5_t_5.onnx");
33 const size_t nROWS = 256, nCOLS = 256;
34 const size_t input_size = 1 * nROWS * nCOLS;
37 std::vector<float> input_values, expected_values;
38 input_values.reserve(input_size);
39 expected_values.reserve(input_size);
40 input_values = utilities::split<float>(model.retrieve<std::string>(
"x_init"),
",");
41 expected_values = utilities::split<float>(model.retrieve<std::string>(
"x_exp"),
",");
44 std::vector<float> output_values = model.compute(input_values, {1,nROWS,nCOLS});
49 for (
size_t i = 0; i < output_values.size(); ++i) {
50 double diff = output_values[i] - expected_values[i];
53 mse /= output_values.size();
Vector< T > diff(const Vector< T > &x)
Numerical derivative of 1d vector.
References sopt::ORTsession::compute(), sopt::gradient_operator::diff(), sopt::tools::models_directory(), and sopt::ORTsession::retrieve().
◆ TEST_CASE() [3/4]
TEST_CASE |
( |
"Check metadata of an example ORT model" |
, |
|
|
"" |
[ONNXrt] |
|
) |
| |
◆ TEST_CASE() [4/4]
TEST_CASE |
( |
"Load an example ORT model" |
, |
|
|
"" |
[ONNXrt] |
|
) |
| |