experimental_experiment.xbuilder.shape_type_compute

experimental_experiment.xbuilder.shape_type_compute.broadcast_shape(sh1: Tuple[int, ...], sh2: Tuple[int, ...], graph_builder: GraphBuilder | None = None) Tuple[int, ...][source]

Computes the shape for many broadcasting operators.

Parameters:
  • sh1 – first shape

  • sh2 – second shape

  • graph_builder – if not None, the function register any constraint which might appear while applying the broadcast

Returns:

resulting shape

experimental_experiment.xbuilder.shape_type_compute.prepare_inputs_homogeneous_operator(g: GraphBuilder, *args: Sequence[str], f: Callable | None = None, outputs: List[str] | None = None, name: str | None = None, sts: Any | None = None, check_shape: bool = True, op_type: str | None = None) Tuple[str, ...][source]

Cast any inputs to ensure all inputs share the same type.

op_type can be specified to bypass some cases with ambiguities such as a float multiplied with an integer.

experimental_experiment.xbuilder.shape_type_compute.set_shape_type_custom(self: GraphBuilder, node: NodeProto)[source]

Sets the shape and type if it can.

experimental_experiment.xbuilder.shape_type_compute.set_shape_type_op_any(self: GraphBuilder, node: NodeProto)[source]

Sets the shape and type if it can.

experimental_experiment.xbuilder.shape_type_compute.set_type_shape_binary_op(g: GraphBuilder, name: str, *input_names: List[str], begin: int = 0, cmp_op: bool = False, itype: int | None = None)[source]

Sets the shape and type for a binary operator (add, mul, …).

experimental_experiment.xbuilder.shape_type_compute.set_type_shape_unary_op(g: GraphBuilder, name: str, input_name: str, itype: int | None = None)[source]

Sets the shape and type for an unary operator (abs, exp, …).