test_case.h#

namespace ONNX_LIGHT_NAMESPACE
namespace onnx_backend_test

Functions

inline OpsetId DefaultOpset(int64_t version)#

Builds an :ref:OpsetId for the default ai.onnx domain (empty string).

void Expect(const NodeProto &node, const std::vector<Tensor> &inputs, const std::vector<Tensor> &outputs, const std::string &name, const std::vector<OpsetId> &opset_imports, const std::string &producer_name, std::vector<TestCase> &registry)#

Builds a single-node ModelProto from node and the provided typed inputs/outputs, then appends a TestCase to registry.

Mirrors onnx_light.backend.test.case.base.expect(). Only the inputs and outputs whose name is non-empty in the node are wired into the graph.

Parameters:
  • node – Single-node template; its op_type, domain and attributes are kept.

  • inputs – Concrete input tensors corresponding to the non-empty entries of node.input.

  • outputs – Concrete expected output tensors corresponding to the non-empty entries of node.output.

  • name – Unique test name (used both for TestCase.name and the graph name).

  • opset_imports – Opset imports for the generated model. If empty the caller is responsible for ensuring a default has been applied — typically pass at least DefaultOpset(since_version).

  • producer_name – Producer name written into the model.

  • registry – Output registry (appended to).

Throws:

std::invalid_argument – if inputs.size() does not equal the number of non-empty entries in node.input or if outputs.size() does not equal the number of non-empty entries in node.output.

std::vector<TestCase> CollectTestCases()#

Collects all C++-implemented backend test node cases. Each call is deterministic and independent: the result owns its ModelProtos and Tensor data.

Returns:

A fresh registry of test cases (Abs, Add equal-shape, Add scalar broadcast).

struct DataSet#
#include <test_case.h>

A single (inputs, expected outputs) data set associated with a TestCase.

Public Members

std::vector<Tensor> inputs#
std::vector<Tensor> outputs#
struct OpsetId#
#include <test_case.h>

Lightweight opset identifier used by the backend test library.

Mirrors the (domain, version) pair carried by OperatorSetIdProto but keeps the public API of this library independent from the proto type so test cases can be declared without touching the proto wire format.

Public Functions

OpsetId() = default#
inline OpsetId(std::string domain_, int64_t version_)#

Public Members

std::string domain#
int64_t version = 0#
struct TestCase#
#include <test_case.h>

A backend test case mirroring onnx_light.backend.test.case.base.TestCase. It bundles a single-node ModelProto together with the expected input/ output data sets a runtime must reproduce.

Public Members

std::string name#
std::string model_name#
std::string kind = "node"#
double rtol = 1e-3#
double atol = 1e-7#
ModelProto model#
std::vector<DataSet> data_sets#