Others…¶
xbuilder.shape_helper¶
compatible_dimensions¶
- experimental_experiment.xbuilder.shape_helper.compatible_dimensions(*dims: Sequence[int | str]) bool [source]¶
Evaluates the fact all the dimensions can be equal or not.
- Parameters:
dims – dimensions
- Returns:
compatibility
<<<
from experimental_experiment.xbuilder.shape_helper import compatible_dimensions print(compatible_dimensions(1, 1)) # True print(compatible_dimensions(1, 2)) # False print(compatible_dimensions(1, "D")) # True print(compatible_dimensions(1, "D", "DD")) # True
>>>
True False True True
compatible_shapes¶
- experimental_experiment.xbuilder.shape_helper.compatible_shapes(sh1: Tuple[int | torch.SymInt | str, ...], sh2: Tuple[int | torch.SymInt | str, ...]) bool [source]¶
Checks that two shapes are compatible. If both static, they must be equal. If dynamic, the variable part must be compatible meaning they could be equal.
- Parameters:
sh1 – first shape
sh2 – seconde shape
- Returns:
compatibility
<<<
from experimental_experiment.xbuilder.shape_helper import compatible_shapes print(compatible_shapes((1, 2), (1, 2))) # True print(compatible_shapes((1, 2), (1, "D2"))) # True print(compatible_shapes(("D2", 2), (1, "D2"))) # False print(compatible_shapes(("D2", 2), (2, "D2"))) # True
>>>
True True False True
xbuilder._onnx_helper¶
choose_consistent_domain_opset¶
- experimental_experiment.xbuilder._onnx_helper.choose_consistent_domain_opset(domain: str, opsets: Dict[str, int] | None = None) int [source]¶
Chooses a compatible opset for a particular domain given this existing one. Only works for ai.onnx.ml, otherwise return 1.
- Parameters:
domain – new domain
opsets – existing opsets
- Returns:
version
compatible_opsets¶
- experimental_experiment.xbuilder._onnx_helper.compatible_opsets(domain: str, op_type: str, current: int, new_version: int) bool [source]¶
Tells if two opset version for a particular operator type means the same version of it.
- Parameters:
domain – domain, only ai.onnx and ai.onnx.ml are checked.
op_type – operator type
current – current domain version
new_version – new version
- Returns:
result
element_wise_binary_op_types¶
- experimental_experiment.xbuilder._onnx_helper.element_wise_binary_op_types() Set[str] [source]¶
Returns the list of element-wise operators.
<<<
import pprint from experimental_experiment.xbuilder._onnx_helper import element_wise_binary_op_types pprint.pprint(element_wise_binary_op_types())
>>>
{'Sub', 'Mod', 'Add', 'Mul', 'Div', 'Xor', 'Or', 'And'}
element_wise_op_cmp_types¶
- experimental_experiment.xbuilder._onnx_helper.element_wise_op_cmp_types() Set[str] [source]¶
Returns the list of element-wise operators doing comparisons.
<<<
import pprint from experimental_experiment.xbuilder._onnx_helper import element_wise_op_cmp_types pprint.pprint(element_wise_op_cmp_types())
>>>
{'Less', 'GreaterOrEqual', 'Equal', 'LessOrEqual', 'Greater'}
unary_like_op_types¶
- experimental_experiment.xbuilder._onnx_helper.unary_like_op_types() Set[str] [source]¶
Returns the list of unary like operators. They do not change the shape. They may change the type.
<<<
import pprint from experimental_experiment.xbuilder._onnx_helper import unary_like_op_types pprint.pprint(unary_like_op_types())
>>>
{'Abs', 'Acos', 'Acosh', 'Asin', 'Asinh', 'Atan', 'Atanh', 'BitShift', 'Cast', 'CastLike', 'Ceil', 'Celu', 'Clip', 'Cos', 'Cosh', 'DequantizeLinear', 'DynamicQuantizeLinear', 'Elu', 'Erf', 'Exp', 'IsInf', 'Log', 'LogSoftmax', 'Neg', 'Not', 'PRelu', 'Pow', 'QuantizeLinear', 'Reciprocal', 'Relu', 'Round', 'Selu', 'Sigmoid', 'Sign', 'Sin', 'Sinh', 'Softmax', 'SoftmaxCrossEntropyLoss', 'Softplus', 'Softsign', 'Sqrt', 'Tan', 'Tanh', 'ThresholdRelu'}