// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #include #include #include "core/session/onnxruntime_c_api.h" namespace ONNX_NAMESPACE { class OpSchema; } // namespace ONNX_NAMESPACE /// A single type constraint entry (e.g., "T" or "T1") from an operator schema. /// Holds the constraint name, allowed data types, and which input/output formal parameters use it. /// Non-owning — lifetime is tied to the parent OrtOpSchema. struct OrtOpSchemaTypeConstraint { std::string type_param_str; // e.g., "T" std::vector allowed_type_strs; // e.g., {"tensor(float)", "tensor(double)"} std::vector allowed_type_ptrs; // C API view into allowed_type_strs std::vector input_indices; // input indices using this constraint std::vector output_indices; // output indices using this constraint }; /// Opaque struct wrapping an ONNX operator schema pointer and its precomputed type constraints. /// Allocated by GetOpSchema and released by ReleaseOpSchema. struct OrtOpSchema { const ONNX_NAMESPACE::OpSchema* onnx_schema; std::vector constraints; // O(1) lookup: input/output index → constraint pointer (nullptr if no constraint) std::vector input_to_constraint; std::vector output_to_constraint; };