shape_math.h#
Shape-inference functions for ONNX operators in the math family.
-
namespace ONNX_LIGHT_NAMESPACE
-
namespace onnx_optim
-
namespace shapes
-
namespace math#
Functions
-
void ComputeShapeAbs(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof anAbsnode and stores it inctx.Absis element-wise and unary in every revision of its schema (v1, v6, v13 — later revisions only widen the accepted dtype set), so the output dtype and shape always match those of the input.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
AbsNodeProtowhose output should be described.node.op_type()must be"Abs"andnodemust declare at least one output.x – Name of the input value to read from
ctx. Must be present inctx.
- Throws:
-
void ComputeShapeAdd(ShapesContext &ctx, const NodeProto &node, const char *a, const char *b)#
Computes the output :cpp:class:
OptimTensorof anAddnode and stores it inctx.Addis element-wise and binary, with numpy-style multidirectional broadcasting between its two operands (since opset 7; earlier revisions had an explicitbroadcastattribute but the shape propagation rules are identical when broadcasting is enabled, which onnx-light assumes). The output dtype matches the input dtype (both operands share the same type via theTtype constraint) and 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
AddNodeProtowhose output should be described.node.op_type()must be"Add"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 ComputeShapeSub(ShapesContext &ctx, const NodeProto &node, const char *a, const char *b)#
Computes the output :cpp:class:
OptimTensorof aSubnode and stores it inctx.Subis element-wise and binary, with numpy-style multidirectional broadcasting between its two operands (since opset 7). The output dtype matches the input dtype (both operands share the same type via theTtype constraint) and 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
SubNodeProtowhose output should be described.node.op_type()must be"Sub"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 ComputeShapeMul(ShapesContext &ctx, const NodeProto &node, const char *a, const char *b)#
Computes the output :cpp:class:
OptimTensorof aMulnode and stores it inctx.Mulis element-wise and binary, with numpy-style multidirectional broadcasting between its two operands (since opset 7). The output dtype matches the input dtype (both operands share the same type via theTtype constraint) and 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
MulNodeProtowhose output should be described.node.op_type()must be"Mul"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 ComputeShapeDiv(ShapesContext &ctx, const NodeProto &node, const char *a, const char *b)#
Computes the output :cpp:class:
OptimTensorof aDivnode and stores it inctx.Divis element-wise and binary, with numpy-style multidirectional broadcasting between its two operands (since opset 7). The output dtype matches the input dtype (both operands share the same type via theTtype constraint) and 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
DivNodeProtowhose output should be described.node.op_type()must be"Div"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 ComputeShapeAcos(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof anAcosnode and stores it inctx.Acosis element-wise and unary in every revision of its schema (v7, v22 — later revisions only widen the accepted dtype set), so the output dtype and shape always match those of the input.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
AcosNodeProtowhose output should be described.node.op_type()must be"Acos"andnodemust declare at least one output.x – Name of the input value to read from
ctx. Must be present inctx.
- Throws:
-
void ComputeShapeAcosh(ShapesContext &ctx, const NodeProto &node, const char *x)#
Computes the output :cpp:class:
OptimTensorof anAcoshnode and stores it inctx.Acoshis element-wise and unary in every revision of its schema (v9, v22 — later revisions only widen the accepted dtype set), so the output dtype and shape always match those of the input.- Parameters:
ctx – In/out context. Must already contain an entry for
x; on return it also contains an entry fornode.output(0).node – The
AcoshNodeProtowhose output should be described.node.op_type()must be"Acosh"andnodemust declare at least one output.x – Name of the input value to read from
ctx. Must be present inctx.
- Throws:
-
void ComputeShapeAbs(ShapesContext &ctx, const NodeProto &node, const char *x)#
-
namespace math#
-
namespace shapes
-
namespace onnx_optim