dim_sum.h#
Helpers to sum many symbolic dimension expressions cheaply.
onnx_light::core::expressions::simplify_expression is super-linear in the number of additive terms it receives, so repeatedly simplifying an ever-growing sum (as happens when profiling large graphs) dominates the cost. :cpp:class:DimSum collapses byte-identical terms into coeff*(term) before simplifying, feeding the simplifier only as many terms as there are distinct expressions while producing a byte-identical result.
-
namespace onnx_light
Alias that makes onnx-light headers compatible with code that references
ONNX_LIGHT_NAMESPACE(the macro used in the standard onnx package).Set to
ONNX_LIGHT_NAMESPACEso both names resolve to the same namespace.Symbol-visibility attribute for the public onnx-light C++ API.
Maps the upstream compatibility macro to onnx-light’s explicit proto ABI annotation. This keeps declarations from vendored ONNX headers visible when
lib_onnx_protouses hidden visibility by default.Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal
onnxnamespace — rather than theONNX_NAMESPACEmacro — resolves to the onnx-light namespace. The standard onnx package lives innamespace onnx; onnx-light usesonnx_light(via ONNX_LIGHT_NAMESPACE), so this alias keeps onnx-light a true drop-in. It is only introduced when the onnx-light namespace differs fromonnx.-
namespace core
-
namespace expressions#
Typedefs
Functions
-
DimType simplify_dim_type(const DimType &value, SimplifiedExpressionCache *cache = nullptr)#
Returns
valueunchanged when it is already a concrete integer, otherwise the canonical simplified form of the symbolic expression it holds (memoized incachewhen provided).
-
class DimSum#
- #include <dim_sum.h>
Accumulates symbolic dimension expressions, grouping identical terms.
Successive :cpp:func:
Addcalls bucket concrete integers into a running constant and identical symbolic expressions into integer coefficients. :cpp:func:Buildemits the packedconstant + c1*(expr1) + c2*(expr2) ...expression and simplifies it once. The result is byte-identical to summing and simplifying each term individually, but the simplifier only ever sees the distinct terms.Public Functions
-
DimType Build(SimplifiedExpressionCache *cache = nullptr) const#
Returns the simplified sum of every added term (
0when empty).
-
DimType Build(SimplifiedExpressionCache *cache = nullptr) const#
-
DimType simplify_dim_type(const DimType &value, SimplifiedExpressionCache *cache = nullptr)#
-
namespace expressions#
-
namespace core