shape_text.h#
Shape-inference functions for ONNX operators in the text family.
-
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.
Defined as empty because onnx-light does not require explicit
__declspec(dllexport)or__attribute__((visibility("default")))annotations — visibility is controlled at the shared-library level. The macro is provided so that vendored ONNX headers that decorate their declarations withONNX_APIcompile without modification.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 onnx_optim
-
namespace shapes
-
namespace text#
Functions
-
void ComputeShapeStringConcat(ShapesContext &ctx, const NodeProto &node, const char *a, const char *b)#
Computes the output :cpp:class:
OptimTensorof aStringConcatnode and stores it inctx.StringConcatconcatenates two string tensors element-wise with numpy-style multidirectional broadcasting (since opset 20 in theai.onnxdomain). The output dtype is always :cpp:enumerator:TensorType::kStringand the output shape is the broadcast of the two input shapes.- Parameters:
ctx – In/out context. Must already contain entries for both
aandb; on return it also contains an entry fornode.output(0).node – The
StringConcatNodeProtowhose output should be described.node.op_type()must be"StringConcat"andnodemust declare at least one output.a – Name of the first input value to read from
ctx.b – Name of the second input value to read from
ctx.
- Throws:
-
void ComputeShapeStringSplit(ShapesContext &ctx, const NodeProto &node, const char *a)#
Computes the output :cpp:class:
OptimTensordescriptors of aStringSplitnode and stores them inctx.StringSplitpreserves the input rank for itsZoutput (substring counts,tensor(int64)) and appends one symbolic final dimension to the input rank for itsYoutput (padded substrings,tensor(string)).- Parameters:
ctx – In/out context. Must already contain an entry for
a; on return it also contains entries fornode.output(0)andnode.output(1).node – The
StringSplitNodeProtowhose outputs should be described.node.op_type()must be"StringSplit"andnodemust declare at least two outputs.a – Name of the input value to read from
ctx.
- Throws:
-
void ComputeShapeStringNormalizer(ShapesContext &ctx, const NodeProto &node, const char *a)#
Computes the output :cpp:class:
OptimTensorof aStringNormalizernode and stores it inctx.StringNormalizeronly accepts[C]- or[1, C]-shapedtensor(string)inputs (since opset 10 in theai.onnxdomain). The output dtype is always :cpp:enumerator:TensorType::kStringand has the same rank as the input. The last dimension of the output is symbolic ("StringNormalizer(<input>)") because it depends on how many entries thestopwordsattribute drops at runtime.- Parameters:
ctx – In/out context. Must already contain an entry for
a; on return it also contains an entry fornode.output(0).node – The
StringNormalizerNodeProtowhose output should be described.node.op_type()must be"StringNormalizer"andnodemust declare at least one output.a – Name of the input value to read from
ctx.
- Throws:
-
void ComputeShapeRegexFullMatch(ShapesContext &ctx, const NodeProto &node, const char *a)#
Computes the output :cpp:class:
OptimTensorof aRegexFullMatchnode and stores it inctx.RegexFullMatch(since opset 20 in theai.onnxdomain) performs an element-wise full-match regex test on atensor(string)input and produces atensor(bool)output of the same shape.- Parameters:
ctx – In/out context. Must already contain an entry for
a; on return it also contains an entry fornode.output(0).node – The
RegexFullMatchNodeProtowhose output should be described.node.op_type()must be"RegexFullMatch"andnodemust declare at least one output.a – Name of the input value to read from
ctx.
- Throws:
-
void ComputeShapeTfIdfVectorizer(ShapesContext &ctx, const NodeProto &node, const char *a)#
Computes the output :cpp:class:
OptimTensorof aTfIdfVectorizernode and stores it inctx.TfIdfVectorizer(since opset 9 in theai.onnxdomain) extracts n-grams from a[C]- or[N, C]-shaped integer / string input and produces atensor(float)whose last dimension ismax(ngram_indexes) + 1. The output preserves the input batch dimension when the input has rank 2.- Parameters:
ctx – In/out context. Must already contain an entry for
a; on return it also contains an entry fornode.output(0).node – The
TfIdfVectorizerNodeProtowhose output should be described.node.op_type()must be"TfIdfVectorizer"andnodemust declare at least one output. Thengram_indexesattribute must be a non-empty list of non-negativeint64s.a – Name of the input value to read from
ctx.
- Throws:
-
void ComputeShapeStringConcat(ShapesContext &ctx, const NodeProto &node, const char *a, const char *b)#
-
namespace text#
-
namespace shapes
-
namespace onnx_optim