9#include <mva/methods/ONNX.h>
10#include <framework/utilities/FileSystem.h>
12#include <gtest/gtest.h>
14using namespace Belle2::MVA::ONNX;
17 TEST(ONNXStandaloneTest, TensorIndexing)
20 EXPECT_EQ(t->at({0, 2}), 3);
21 EXPECT_EQ(t->at({1, 2}), 6);
23 EXPECT_EQ(t->at(4), 42);
24 EXPECT_EQ(t->at({1, 1}), 42);
26 TEST(ONNXStandaloneTest, BoundsCheck)
29 EXPECT_THROW(t->at({2, 0}), std::out_of_range);
31 TEST(ONNXStandaloneTest, SizeCheck)
33 EXPECT_THROW(
Tensor<int>({1, 2, 3}, {2, 2}), std::length_error);
35 TEST(ONNXStandaloneTest, RunStandaloneModel)
42 session.run({{
"a", input_a}, {
"b", input_b}}, {{
"output", output}});
43 EXPECT_NEAR(output->at(0), -0.0614375323, 0.000000001);
44 EXPECT_NEAR(output->at(1), 0.3322576284, 0.000000001);
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
A wrapper around Ort::Session providing model execution.
Represents an input or output tensor for an ONNX model.
static auto make_shared(std::vector< int64_t > shape)
Convenience method to create a shared pointer to a Tensor from shape.