onnxscript 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. onnxscript/__init__.py +131 -0
  2. onnxscript/_framework_apis/__init__.py +3 -0
  3. onnxscript/_framework_apis/torch_2_5.py +117 -0
  4. onnxscript/_framework_apis/torch_2_6.py +45 -0
  5. onnxscript/_internal/__init__.py +0 -0
  6. onnxscript/_internal/analysis.py +229 -0
  7. onnxscript/_internal/ast_utils.py +64 -0
  8. onnxscript/_internal/autocast.py +250 -0
  9. onnxscript/_internal/deprecation.py +78 -0
  10. onnxscript/_internal/param_manipulation.py +148 -0
  11. onnxscript/_internal/runtime_typing.py +43 -0
  12. onnxscript/_internal/utils.py +99 -0
  13. onnxscript/_internal/version_utils.py +118 -0
  14. onnxscript/_legacy_ir/__init__.py +341 -0
  15. onnxscript/_legacy_ir/visitor.py +937 -0
  16. onnxscript/_thirdparty/asciichartpy.py +313 -0
  17. onnxscript/backend/__init__.py +2 -0
  18. onnxscript/backend/onnx_backend.py +303 -0
  19. onnxscript/backend/onnx_export.py +885 -0
  20. onnxscript/converter.py +1470 -0
  21. onnxscript/evaluator.py +619 -0
  22. onnxscript/function_libs/tools/torch_lib/deduce_type_constraints.py +403 -0
  23. onnxscript/function_libs/tools/torch_lib/generate_aten_signatures.py +333 -0
  24. onnxscript/function_libs/tools/torch_lib/generate_prims_signatures.py +331 -0
  25. onnxscript/function_libs/torch_lib/__init__.py +12 -0
  26. onnxscript/function_libs/torch_lib/_constants.py +5 -0
  27. onnxscript/function_libs/torch_lib/_flags.py +58 -0
  28. onnxscript/function_libs/torch_lib/graph_building/__init__.py +56 -0
  29. onnxscript/function_libs/torch_lib/graph_building/_graph_building_ir.py +723 -0
  30. onnxscript/function_libs/torch_lib/graph_building/_graph_building_torch.py +1125 -0
  31. onnxscript/function_libs/torch_lib/ops/__init__.py +27 -0
  32. onnxscript/function_libs/torch_lib/ops/common.py +80 -0
  33. onnxscript/function_libs/torch_lib/ops/core.py +8935 -0
  34. onnxscript/function_libs/torch_lib/ops/fft.py +385 -0
  35. onnxscript/function_libs/torch_lib/ops/linalg.py +399 -0
  36. onnxscript/function_libs/torch_lib/ops/nested.py +25 -0
  37. onnxscript/function_libs/torch_lib/ops/nn.py +2713 -0
  38. onnxscript/function_libs/torch_lib/ops/prims.py +850 -0
  39. onnxscript/function_libs/torch_lib/ops/quantized_decomposed.py +63 -0
  40. onnxscript/function_libs/torch_lib/ops/sparse.py +23 -0
  41. onnxscript/function_libs/torch_lib/ops/special.py +387 -0
  42. onnxscript/function_libs/torch_lib/ops/vision.py +25 -0
  43. onnxscript/function_libs/torch_lib/registration.py +151 -0
  44. onnxscript/function_libs/torch_lib/tensor_typing.py +74 -0
  45. onnxscript/ir/__init__.py +153 -0
  46. onnxscript/ir/_convenience.py +447 -0
  47. onnxscript/ir/_core.py +3119 -0
  48. onnxscript/ir/_display.py +49 -0
  49. onnxscript/ir/_enums.py +163 -0
  50. onnxscript/ir/_graph_comparison.py +23 -0
  51. onnxscript/ir/_io.py +97 -0
  52. onnxscript/ir/_linked_list.py +276 -0
  53. onnxscript/ir/_metadata.py +44 -0
  54. onnxscript/ir/_name_authority.py +72 -0
  55. onnxscript/ir/_polyfill.py +25 -0
  56. onnxscript/ir/_protocols.py +598 -0
  57. onnxscript/ir/_schemas.py +548 -0
  58. onnxscript/ir/_tape.py +120 -0
  59. onnxscript/ir/_type_casting.py +106 -0
  60. onnxscript/ir/convenience.py +32 -0
  61. onnxscript/ir/external_data.py +396 -0
  62. onnxscript/ir/passes/__init__.py +33 -0
  63. onnxscript/ir/passes/_pass_infra.py +172 -0
  64. onnxscript/ir/serde.py +1620 -0
  65. onnxscript/ir/tensor_adapters.py +122 -0
  66. onnxscript/ir/traversal.py +82 -0
  67. onnxscript/irbuilder.py +542 -0
  68. onnxscript/main.py +167 -0
  69. onnxscript/onnx_opset/__init__.py +232 -0
  70. onnxscript/onnx_opset/_impl/opset1.py +4100 -0
  71. onnxscript/onnx_opset/_impl/opset10.py +1227 -0
  72. onnxscript/onnx_opset/_impl/opset11.py +4013 -0
  73. onnxscript/onnx_opset/_impl/opset12.py +1078 -0
  74. onnxscript/onnx_opset/_impl/opset13.py +3924 -0
  75. onnxscript/onnx_opset/_impl/opset14.py +999 -0
  76. onnxscript/onnx_opset/_impl/opset15.py +604 -0
  77. onnxscript/onnx_opset/_impl/opset16.py +1255 -0
  78. onnxscript/onnx_opset/_impl/opset17.py +561 -0
  79. onnxscript/onnx_opset/_impl/opset18.py +1803 -0
  80. onnxscript/onnx_opset/_impl/opset19.py +1942 -0
  81. onnxscript/onnx_opset/_impl/opset2.py +218 -0
  82. onnxscript/onnx_opset/_impl/opset20.py +675 -0
  83. onnxscript/onnx_opset/_impl/opset21.py +1976 -0
  84. onnxscript/onnx_opset/_impl/opset22.py +2588 -0
  85. onnxscript/onnx_opset/_impl/opset3.py +199 -0
  86. onnxscript/onnx_opset/_impl/opset4.py +77 -0
  87. onnxscript/onnx_opset/_impl/opset5.py +84 -0
  88. onnxscript/onnx_opset/_impl/opset6.py +944 -0
  89. onnxscript/onnx_opset/_impl/opset7.py +1243 -0
  90. onnxscript/onnx_opset/_impl/opset8.py +444 -0
  91. onnxscript/onnx_opset/_impl/opset9.py +1485 -0
  92. onnxscript/onnx_opset/_impl/opset_ai_onnx_ml1.py +974 -0
  93. onnxscript/onnx_opset/_impl/opset_ai_onnx_ml2.py +112 -0
  94. onnxscript/onnx_opset/_impl/opset_ai_onnx_ml3.py +308 -0
  95. onnxscript/onnx_opset/_impl/opset_ai_onnx_ml4.py +129 -0
  96. onnxscript/onnx_opset/_impl/opset_ai_onnx_ml5.py +158 -0
  97. onnxscript/onnx_opset/_impl/opset_ai_onnx_preview_training1.py +577 -0
  98. onnxscript/onnx_types.py +229 -0
  99. onnxscript/optimizer/__init__.py +39 -0
  100. onnxscript/optimizer/_constant_folding.py +1083 -0
  101. onnxscript/optimizer/_inliner.py +312 -0
  102. onnxscript/optimizer/_legacy/_optimizer.py +98 -0
  103. onnxscript/optimizer/_legacy/_remove_unused_proto.py +144 -0
  104. onnxscript/optimizer/_legacy/_simple_function_folding.py +243 -0
  105. onnxscript/optimizer/_legacy/constant_folding.py +293 -0
  106. onnxscript/optimizer/_legacy/evaluator.py +439 -0
  107. onnxscript/optimizer/_optimizer.py +61 -0
  108. onnxscript/optimizer/_remove_unused.py +106 -0
  109. onnxscript/optimizer/_remove_unused_function.py +72 -0
  110. onnxscript/py.typed +1 -0
  111. onnxscript/rewriter/__init__.py +56 -0
  112. onnxscript/rewriter/_ir_utils.py +111 -0
  113. onnxscript/rewriter/broadcast_to_matmul.py +180 -0
  114. onnxscript/rewriter/cast_constant_of_shape.py +50 -0
  115. onnxscript/rewriter/collapse_slices.py +141 -0
  116. onnxscript/rewriter/erfgelu.py +27 -0
  117. onnxscript/rewriter/function_rule.py +232 -0
  118. onnxscript/rewriter/gemm_to_matmul_add.py +21 -0
  119. onnxscript/rewriter/generic_pattern.py +700 -0
  120. onnxscript/rewriter/llama_rule_sets.py +287 -0
  121. onnxscript/rewriter/no_op.py +56 -0
  122. onnxscript/rewriter/onnxruntime/__init__.py +50 -0
  123. onnxscript/rewriter/onnxruntime/bfloat16_utils/bfloat16_converter.py +99 -0
  124. onnxscript/rewriter/onnxruntime/fused_matmul_rule_sets.py +177 -0
  125. onnxscript/rewriter/onnxruntime/group_normalization_merge_silu.py +64 -0
  126. onnxscript/rewriter/onnxruntime/instance_to_group_normalization.py +155 -0
  127. onnxscript/rewriter/onnxruntime/softmax.py +63 -0
  128. onnxscript/rewriter/onnxruntime/transformers/__init__.py +21 -0
  129. onnxscript/rewriter/onnxruntime/transformers/biassplitgelu.py +31 -0
  130. onnxscript/rewriter/onnxruntime/transformers/fastgelu.py +29 -0
  131. onnxscript/rewriter/onnxruntime/transformers/layernorm.py +47 -0
  132. onnxscript/rewriter/onnxruntime/transformers/multihead_attention.py +715 -0
  133. onnxscript/rewriter/ort_fusions/__init__.py +9 -0
  134. onnxscript/rewriter/ort_fusions/_core.py +28 -0
  135. onnxscript/rewriter/ort_fusions/_smollm_1.py +253 -0
  136. onnxscript/rewriter/ort_fusions/_smollm_2.py +467 -0
  137. onnxscript/rewriter/ort_fusions/_test_models.py +122 -0
  138. onnxscript/rewriter/ort_fusions/_test_utils.py +42 -0
  139. onnxscript/rewriter/ort_fusions/cos_sin_cache.py +154 -0
  140. onnxscript/rewriter/ort_fusions/gqa.py +156 -0
  141. onnxscript/rewriter/ort_fusions/mha.py +198 -0
  142. onnxscript/rewriter/ort_fusions/rms_normalization.py +95 -0
  143. onnxscript/rewriter/ort_fusions/rotary_embedding.py +64 -0
  144. onnxscript/rewriter/ort_fusions/sdpa.py +75 -0
  145. onnxscript/rewriter/ort_fusions/skip_normalization.py +46 -0
  146. onnxscript/rewriter/pattern.py +1714 -0
  147. onnxscript/rewriter/testing.py +77 -0
  148. onnxscript/sourceinfo.py +59 -0
  149. onnxscript/tensor.py +227 -0
  150. onnxscript/testing/__init__.py +482 -0
  151. onnxscript/tools/__init__.py +4 -0
  152. onnxscript/tools/benchmark/__init__.py +23 -0
  153. onnxscript/tools/benchmark/benchmark_helpers.py +783 -0
  154. onnxscript/tools/benchmark/benchmark_run.py +140 -0
  155. onnxscript/tools/benchmark/export_model.py +207 -0
  156. onnxscript/tools/benchmark/export_model_batch.py +146 -0
  157. onnxscript/tools/memory_peak.py +244 -0
  158. onnxscript/tools/training_helper.py +50 -0
  159. onnxscript/tools/transformers_models/__init__.py +190 -0
  160. onnxscript/tools/transformers_models/llama.py +168 -0
  161. onnxscript/tools/transformers_models/mistral.py +238 -0
  162. onnxscript/tools/transformers_models/phi.py +248 -0
  163. onnxscript/tools/transformers_models/phi3.py +259 -0
  164. onnxscript/type_annotation.py +281 -0
  165. onnxscript/utils/__init__.py +0 -0
  166. onnxscript/utils/evaluation_utils.py +56 -0
  167. onnxscript/utils/timing_utils.py +33 -0
  168. onnxscript/utils/utils.py +84 -0
  169. onnxscript/values.py +790 -0
  170. onnxscript/version_converter/__init__.py +21 -0
  171. onnxscript/version_converter/_version_converter.py +314 -0
  172. onnxscript-0.1.0.dist-info/LICENSE +21 -0
  173. onnxscript-0.1.0.dist-info/METADATA +370 -0
  174. onnxscript-0.1.0.dist-info/RECORD +176 -0
  175. onnxscript-0.1.0.dist-info/WHEEL +5 -0
  176. onnxscript-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,944 @@
1
+ # --------------------------------------------------------------------------
2
+ # ⚠️ WARNING - AUTO-GENERATED CODE - DO NOT EDIT ⚠️
3
+ # ⚙️ Generated by 'python -m opgen'
4
+ # --------------------------------------------------------------------------
5
+ # Copyright (c) Microsoft Corporation. All rights reserved.
6
+ # Licensed under the MIT License.
7
+ # --------------------------------------------------------------------------
8
+ # pylint: disable=W0221,W0222,R0901,W0237
9
+ # mypy: disable-error-code=override
10
+ # ruff: noqa: N801,E741
11
+ # ruff: noqa: D214,D402,D405,D411,D412,D416,D417
12
+ # --------------------------------------------------------------------------
13
+
14
+ from __future__ import annotations
15
+
16
+ from typing import Optional, Tuple, TypeVar, Union
17
+
18
+ from onnx.defs import get_schema
19
+ from typing_extensions import TypeAlias
20
+
21
+ from onnxscript.onnx_opset._impl.opset5 import Opset5
22
+ from onnxscript.onnx_types import (
23
+ BOOL,
24
+ COMPLEX64,
25
+ COMPLEX128,
26
+ DOUBLE,
27
+ FLOAT,
28
+ FLOAT16,
29
+ INT8,
30
+ INT16,
31
+ INT32,
32
+ INT64,
33
+ STRING,
34
+ UINT8,
35
+ UINT16,
36
+ UINT32,
37
+ UINT64,
38
+ )
39
+ from onnxscript.values import Op, Opset
40
+
41
+
42
+ class Opset6(Opset5):
43
+ def __new__(cls):
44
+ return Opset.__new__(cls, "", 6)
45
+
46
+ T_Abs = TypeVar(
47
+ "T_Abs",
48
+ DOUBLE,
49
+ FLOAT,
50
+ FLOAT16,
51
+ INT16,
52
+ INT32,
53
+ INT64,
54
+ INT8,
55
+ UINT16,
56
+ UINT32,
57
+ UINT64,
58
+ UINT8,
59
+ )
60
+
61
+ def Abs(self, X: T_Abs) -> T_Abs:
62
+ r"""[🌐 Abs(6)](https://onnx.ai/onnx/operators/onnx__Abs.html#abs-6 "Online Documentation")
63
+
64
+
65
+ Absolute takes one input data (Tensor<T>) and produces one output data
66
+ (Tensor<T>) where the absolute is, y = abs(x), is applied to
67
+ the tensor elementwise.
68
+
69
+
70
+ Args:
71
+ X: Input tensor
72
+ """
73
+
74
+ schema = get_schema("Abs", 6, "")
75
+ op = Op(self, "Abs", schema)
76
+ return op(*self._prepare_inputs(schema, X))
77
+
78
+ T_Add = TypeVar("T_Add", DOUBLE, FLOAT, FLOAT16, INT32, INT64, UINT32, UINT64)
79
+
80
+ def Add(
81
+ self, A: T_Add, B: T_Add, *, axis: Optional[int] = None, broadcast: int = 0
82
+ ) -> T_Add:
83
+ r"""[🌐 Add(6)](https://onnx.ai/onnx/operators/onnx__Add.html#add-6 "Online Documentation")
84
+
85
+
86
+ Performs element-wise binary addition (with limited broadcast support).
87
+
88
+ If necessary the right-hand-side argument will be broadcasted to match the
89
+ shape of left-hand-side argument. When broadcasting is specified, the second
90
+ tensor can either be of element size 1 (including a scalar tensor and any
91
+ tensor with rank equal to or smaller than the first tensor), or having its
92
+ shape as a contiguous subset of the first tensor's shape. The starting of the
93
+ mutually equal shape is specified by the argument "axis", and if it is not set,
94
+ suffix matching is assumed. 1-dim expansion doesn't work yet.
95
+
96
+ For example, the following tensor shapes are supported (with broadcast=1):
97
+
98
+ shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
99
+ shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
100
+ shape(A) = (2, 3, 4, 5), shape(B) = (5,)
101
+ shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
102
+ shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
103
+ shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0
104
+
105
+ Attribute `broadcast=1` needs to be passed to enable broadcasting.
106
+
107
+
108
+ Args:
109
+ A: First operand, should share the type with the second operand.
110
+
111
+ B: Second operand. With broadcasting can be of smaller size than A. If
112
+ broadcasting is disabled it should be of the same size.
113
+
114
+ axis: If set, defines the broadcast dimensions. See doc for details.
115
+
116
+ broadcast: Pass 1 to enable broadcasting
117
+ """
118
+
119
+ schema = get_schema("Add", 6, "")
120
+ op = Op(self, "Add", schema)
121
+ return op(*self._prepare_inputs(schema, A, B), axis=axis, broadcast=broadcast)
122
+
123
+ T_BatchNormalization = TypeVar("T_BatchNormalization", DOUBLE, FLOAT, FLOAT16)
124
+
125
+ def BatchNormalization(
126
+ self,
127
+ X: T_BatchNormalization,
128
+ scale: T_BatchNormalization,
129
+ B: T_BatchNormalization,
130
+ mean: T_BatchNormalization,
131
+ var: T_BatchNormalization,
132
+ *,
133
+ epsilon: float = 9.999999747378752e-06,
134
+ is_test: int = 0,
135
+ momentum: float = 0.8999999761581421,
136
+ spatial: int = 1,
137
+ ) -> Tuple[
138
+ T_BatchNormalization,
139
+ T_BatchNormalization,
140
+ T_BatchNormalization,
141
+ T_BatchNormalization,
142
+ T_BatchNormalization,
143
+ ]:
144
+ r"""[🌐 BatchNormalization(6)](https://onnx.ai/onnx/operators/onnx__BatchNormalization.html#batchnormalization-6 "Online Documentation")
145
+
146
+
147
+ Carries out batch normalization as described in the paper
148
+ https://arxiv.org/abs/1502.03167. Depending on the mode it is being run,
149
+ there are multiple cases for the number of outputs, which we list below:
150
+
151
+ Output case #1: Y, mean, var, saved_mean, saved_var (training mode)
152
+ Output case #2: Y (test mode)
153
+
154
+
155
+ Args:
156
+ X: Input data tensor from the previous operator; dimensions for image case
157
+ are (N x C x H x W), where N is the batch size, C is the number of
158
+ channels, and H and W are the height and the width of the data. For non
159
+ image case, the dimensions are in the form of (N x C x D1 x D2 ... Dn),
160
+ where N is the batch size.
161
+
162
+ scale: The scale as a 1-dimensional tensor of size C to be applied to the
163
+ output.
164
+
165
+ B: The bias as a 1-dimensional tensor of size C to be applied to the output.
166
+
167
+ mean: The running mean (training) or the estimated mean (testing) as a
168
+ 1-dimensional tensor of size C.
169
+
170
+ var: The running variance (training) or the estimated variance (testing) as
171
+ a 1-dimensional tensor of size C.
172
+
173
+ epsilon: The epsilon value to use to avoid division by zero, default is
174
+ 1e-5f.
175
+
176
+ is_test: If set to nonzero, run spatial batch normalization in test mode,
177
+ default is 0.
178
+
179
+ momentum: Factor used in computing the running mean and variance.e.g.,
180
+ running_mean = running_mean * momentum + mean * (1 - momentum), default
181
+ is 0.9f.
182
+
183
+ spatial: If true, compute the mean and variance across all spatial elements
184
+ If false, compute the mean and variance across per feature.Default is 1.
185
+ """
186
+
187
+ schema = get_schema("BatchNormalization", 6, "")
188
+ op = Op(self, "BatchNormalization", schema)
189
+ return op(
190
+ *self._prepare_inputs(schema, X, scale, B, mean, var),
191
+ epsilon=epsilon,
192
+ is_test=is_test,
193
+ momentum=momentum,
194
+ spatial=spatial,
195
+ )
196
+
197
+ T1_Cast = TypeVar(
198
+ "T1_Cast",
199
+ BOOL,
200
+ DOUBLE,
201
+ FLOAT,
202
+ FLOAT16,
203
+ INT16,
204
+ INT32,
205
+ INT64,
206
+ INT8,
207
+ UINT16,
208
+ UINT32,
209
+ UINT64,
210
+ UINT8,
211
+ )
212
+
213
+ T2_Cast: TypeAlias = Union[
214
+ BOOL, DOUBLE, FLOAT, FLOAT16, INT16, INT32, INT64, INT8, UINT16, UINT32, UINT64, UINT8
215
+ ]
216
+
217
+ def Cast(self, input: T1_Cast, *, to: int) -> T2_Cast:
218
+ r"""[🌐 Cast(6)](https://onnx.ai/onnx/operators/onnx__Cast.html#cast-6 "Online Documentation")
219
+
220
+
221
+ The operator casts the elements of a given input tensor to a data type
222
+ specified by the 'to' argument and returns an output tensor of the same size in
223
+ the converted type. The 'to' argument must be one of the data types specified
224
+ in the 'DataType' enum field in the TensorProto message.
225
+ NOTE: Casting to and from strings is not supported yet.
226
+
227
+
228
+ Args:
229
+ input: Input tensor to be cast.
230
+
231
+ to: The data type to which the elements of the input tensor are cast.
232
+ Strictly must be one of the types from DataType enum in TensorProto
233
+ """
234
+
235
+ schema = get_schema("Cast", 6, "")
236
+ op = Op(self, "Cast", schema)
237
+ return op(*self._prepare_inputs(schema, input), to=to)
238
+
239
+ T_Ceil = TypeVar("T_Ceil", DOUBLE, FLOAT, FLOAT16)
240
+
241
+ def Ceil(self, X: T_Ceil) -> T_Ceil:
242
+ r"""[🌐 Ceil(6)](https://onnx.ai/onnx/operators/onnx__Ceil.html#ceil-6 "Online Documentation")
243
+
244
+
245
+ Ceil takes one input data (Tensor<T>) and produces one output data
246
+ (Tensor<T>) where the ceil is, y = ceil(x), is applied to
247
+ the tensor elementwise.
248
+
249
+
250
+ Args:
251
+ X: Input tensor
252
+ """
253
+
254
+ schema = get_schema("Ceil", 6, "")
255
+ op = Op(self, "Ceil", schema)
256
+ return op(*self._prepare_inputs(schema, X))
257
+
258
+ T_Clip = TypeVar("T_Clip", DOUBLE, FLOAT, FLOAT16)
259
+
260
+ def Clip(
261
+ self,
262
+ input: T_Clip,
263
+ *,
264
+ max: float = 3.4028234663852886e38,
265
+ min: float = -3.4028234663852886e38,
266
+ ) -> T_Clip:
267
+ r"""[🌐 Clip(6)](https://onnx.ai/onnx/operators/onnx__Clip.html#clip-6 "Online Documentation")
268
+
269
+
270
+ Clip operator limits the given input within an interval. The interval is
271
+ specified with arguments 'min' and 'max'. They default to
272
+ numeric_limits::lowest() and numeric_limits::max() respectively.
273
+
274
+
275
+ Args:
276
+ input: Input tensor whose elements to be clipped
277
+
278
+ max: Maximum value, above which element is replaced by max
279
+
280
+ min: Minimum value, under which element is replaced by min
281
+ """
282
+
283
+ schema = get_schema("Clip", 6, "")
284
+ op = Op(self, "Clip", schema)
285
+ return op(*self._prepare_inputs(schema, input), max=max, min=min)
286
+
287
+ T_Div = TypeVar("T_Div", DOUBLE, FLOAT, FLOAT16, INT32, INT64, UINT32, UINT64)
288
+
289
+ def Div(
290
+ self, A: T_Div, B: T_Div, *, axis: Optional[int] = None, broadcast: int = 0
291
+ ) -> T_Div:
292
+ r"""[🌐 Div(6)](https://onnx.ai/onnx/operators/onnx__Div.html#div-6 "Online Documentation")
293
+
294
+
295
+ Performs element-wise binary division (with limited broadcast support).
296
+
297
+ If necessary the right-hand-side argument will be broadcasted to match the
298
+ shape of left-hand-side argument. When broadcasting is specified, the second
299
+ tensor can either be of element size 1 (including a scalar tensor and any
300
+ tensor with rank equal to or smaller than the first tensor), or having its
301
+ shape as a contiguous subset of the first tensor's shape. The starting of the
302
+ mutually equal shape is specified by the argument "axis", and if it is not set,
303
+ suffix matching is assumed. 1-dim expansion doesn't work yet.
304
+
305
+ For example, the following tensor shapes are supported (with broadcast=1):
306
+
307
+ shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
308
+ shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
309
+ shape(A) = (2, 3, 4, 5), shape(B) = (5,)
310
+ shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
311
+ shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
312
+ shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0
313
+
314
+ Attribute `broadcast=1` needs to be passed to enable broadcasting.
315
+
316
+
317
+ Args:
318
+ A: First operand, should share the type with the second operand.
319
+
320
+ B: Second operand. With broadcasting can be of smaller size than A. If
321
+ broadcasting is disabled it should be of the same size.
322
+
323
+ axis: If set, defines the broadcast dimensions. See doc for details.
324
+
325
+ broadcast: Pass 1 to enable broadcasting
326
+ """
327
+
328
+ schema = get_schema("Div", 6, "")
329
+ op = Op(self, "Div", schema)
330
+ return op(*self._prepare_inputs(schema, A, B), axis=axis, broadcast=broadcast)
331
+
332
+ T_Dropout = TypeVar("T_Dropout", DOUBLE, FLOAT, FLOAT16)
333
+
334
+ def Dropout(
335
+ self, data: T_Dropout, *, is_test: int = 0, ratio: float = 0.5
336
+ ) -> Tuple[T_Dropout, T_Dropout]:
337
+ r"""[🌐 Dropout(6)](https://onnx.ai/onnx/operators/onnx__Dropout.html#dropout-6 "Online Documentation")
338
+
339
+
340
+ Dropout takes one input data (Tensor<float>) and produces two Tensor outputs,
341
+ output (Tensor<float>) and mask (Tensor<bool>). Depending on whether it is in
342
+ test mode or not, the output Y will either be a random dropout, or a simple
343
+ copy of the input. Note that our implementation of Dropout does scaling in
344
+ the training phase, so during testing nothing needs to be done.
345
+
346
+
347
+ Args:
348
+ data: The input data as Tensor.
349
+
350
+ is_test: (int, default 0) if nonzero, run dropout in test mode where the
351
+ output is simply Y = X.
352
+
353
+ ratio: (float, default 0.5) the ratio of random dropout
354
+ """
355
+
356
+ schema = get_schema("Dropout", 6, "")
357
+ op = Op(self, "Dropout", schema)
358
+ return op(*self._prepare_inputs(schema, data), is_test=is_test, ratio=ratio)
359
+
360
+ T_Elu = TypeVar("T_Elu", DOUBLE, FLOAT, FLOAT16)
361
+
362
+ def Elu(self, X: T_Elu, *, alpha: float = 1.0) -> T_Elu:
363
+ r"""[🌐 Elu(6)](https://onnx.ai/onnx/operators/onnx__Elu.html#elu-6 "Online Documentation")
364
+
365
+
366
+ Elu takes one input data (Tensor<T>) and produces one output data
367
+ (Tensor<T>) where the function `f(x) = alpha * (exp(x) - 1.) for x <
368
+ 0`, `f(x) = x for x >= 0`., is applied to the tensor elementwise.
369
+
370
+
371
+
372
+ Args:
373
+ X: (differentiable) 1D input tensor
374
+
375
+ alpha: Coefficient of ELU.
376
+ """
377
+
378
+ schema = get_schema("Elu", 6, "")
379
+ op = Op(self, "Elu", schema)
380
+ return op(*self._prepare_inputs(schema, X), alpha=alpha)
381
+
382
+ T_Exp = TypeVar("T_Exp", DOUBLE, FLOAT, FLOAT16)
383
+
384
+ def Exp(self, input: T_Exp) -> T_Exp:
385
+ r"""[🌐 Exp(6)](https://onnx.ai/onnx/operators/onnx__Exp.html#exp-6 "Online Documentation")
386
+
387
+
388
+ Calculates the exponential of the given input tensor, element-wise.
389
+
390
+
391
+ Args:
392
+ input: Input tensor
393
+ """
394
+
395
+ schema = get_schema("Exp", 6, "")
396
+ op = Op(self, "Exp", schema)
397
+ return op(*self._prepare_inputs(schema, input))
398
+
399
+ T_Floor = TypeVar("T_Floor", DOUBLE, FLOAT, FLOAT16)
400
+
401
+ def Floor(self, X: T_Floor) -> T_Floor:
402
+ r"""[🌐 Floor(6)](https://onnx.ai/onnx/operators/onnx__Floor.html#floor-6 "Online Documentation")
403
+
404
+
405
+ Floor takes one input data (Tensor<T>) and produces one output data
406
+ (Tensor<T>) where the floor is, y = floor(x), is applied to
407
+ the tensor elementwise.
408
+
409
+
410
+ Args:
411
+ X: Input tensor
412
+ """
413
+
414
+ schema = get_schema("Floor", 6, "")
415
+ op = Op(self, "Floor", schema)
416
+ return op(*self._prepare_inputs(schema, X))
417
+
418
+ T_Gemm = TypeVar("T_Gemm", DOUBLE, FLOAT, FLOAT16)
419
+
420
+ def Gemm(
421
+ self,
422
+ A: T_Gemm,
423
+ B: T_Gemm,
424
+ C: T_Gemm,
425
+ *,
426
+ alpha: float = 1.0,
427
+ beta: float = 1.0,
428
+ broadcast: int = 0,
429
+ transA: int = 0,
430
+ transB: int = 0,
431
+ ) -> T_Gemm:
432
+ r"""[🌐 Gemm(6)](https://onnx.ai/onnx/operators/onnx__Gemm.html#gemm-6 "Online Documentation")
433
+
434
+ General Matrix multiplication:
435
+ https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms#Level_3
436
+ Compute Y = alpha * A * B + beta * C, where input tensor A has
437
+ dimension (M X K), input tensor B has dimension (K X N), input tensor C and
438
+ output tensor Y have dimension (M X N).
439
+ If attribute broadcast is non-zero, input tensor C will be broadcasted to match
440
+ the dimension requirement. A will be transposed before doing the computation
441
+ if attribute transA is non-zero, same for B and transB.
442
+
443
+
444
+ Args:
445
+ A: Input tensor A
446
+
447
+ B: Input tensor B
448
+
449
+ C: Input tensor C
450
+
451
+ alpha: Scalar multiplier for the product of input tensors A * B, the default
452
+ value is 1.0.
453
+
454
+ beta: Scalar multiplier for input tensor C, the default value is 1.0.
455
+
456
+ broadcast: Whether C should be broadcasted
457
+
458
+ transA: Whether A should be transposed
459
+
460
+ transB: Whether B should be transposed
461
+ """
462
+
463
+ schema = get_schema("Gemm", 6, "")
464
+ op = Op(self, "Gemm", schema)
465
+ return op(
466
+ *self._prepare_inputs(schema, A, B, C),
467
+ alpha=alpha,
468
+ beta=beta,
469
+ broadcast=broadcast,
470
+ transA=transA,
471
+ transB=transB,
472
+ )
473
+
474
+ T_HardSigmoid = TypeVar("T_HardSigmoid", DOUBLE, FLOAT, FLOAT16)
475
+
476
+ def HardSigmoid(
477
+ self, X: T_HardSigmoid, *, alpha: float = 0.20000000298023224, beta: float = 0.5
478
+ ) -> T_HardSigmoid:
479
+ r"""[🌐 HardSigmoid(6)](https://onnx.ai/onnx/operators/onnx__HardSigmoid.html#hardsigmoid-6 "Online Documentation")
480
+
481
+
482
+ HardSigmoid takes one input data (Tensor<T>) and produces one output data
483
+ (Tensor<T>) where the HardSigmoid function, y = max(0, min(1, alpha * x + beta)),
484
+ is applied to the tensor elementwise.
485
+
486
+
487
+ Args:
488
+ X: (differentiable) Input tensor
489
+
490
+ alpha: Value of alpha.
491
+
492
+ beta: Value of beta.
493
+ """
494
+
495
+ schema = get_schema("HardSigmoid", 6, "")
496
+ op = Op(self, "HardSigmoid", schema)
497
+ return op(*self._prepare_inputs(schema, X), alpha=alpha, beta=beta)
498
+
499
+ T_InstanceNormalization = TypeVar("T_InstanceNormalization", DOUBLE, FLOAT, FLOAT16)
500
+
501
+ def InstanceNormalization(
502
+ self,
503
+ input: T_InstanceNormalization,
504
+ scale: T_InstanceNormalization,
505
+ B: T_InstanceNormalization,
506
+ *,
507
+ epsilon: float = 9.999999747378752e-06,
508
+ ) -> T_InstanceNormalization:
509
+ r"""[🌐 InstanceNormalization(6)](https://onnx.ai/onnx/operators/onnx__InstanceNormalization.html#instancenormalization-6 "Online Documentation")
510
+
511
+
512
+ Carries out instance normalization as described in the paper
513
+ https://arxiv.org/abs/1607.08022.
514
+
515
+ y = scale * (x - mean) / sqrt(variance + epsilon) + B,
516
+ where mean and variance are computed per instance per channel.
517
+
518
+
519
+
520
+ Args:
521
+ input: (differentiable) Input data tensor from the previous operator;
522
+ dimensions for image case are (N x C x H x W), where N is the batch
523
+ size, C is the number of channels, and H and W are the height and the
524
+ width of the data. For non image case, the dimensions are in the form of
525
+ (N x C x D1 x D2 ... Dn), where N is the batch size.
526
+
527
+ scale: (differentiable) The input 1-dimensional scale tensor of size C.
528
+
529
+ B: (differentiable) The input 1-dimensional bias tensor of size C.
530
+
531
+ epsilon: The epsilon value to use to avoid division by zero.
532
+ """
533
+
534
+ schema = get_schema("InstanceNormalization", 6, "")
535
+ op = Op(self, "InstanceNormalization", schema)
536
+ return op(*self._prepare_inputs(schema, input, scale, B), epsilon=epsilon)
537
+
538
+ T_LeakyRelu = TypeVar("T_LeakyRelu", DOUBLE, FLOAT, FLOAT16)
539
+
540
+ def LeakyRelu(self, X: T_LeakyRelu, *, alpha: float = 0.009999999776482582) -> T_LeakyRelu:
541
+ r"""[🌐 LeakyRelu(6)](https://onnx.ai/onnx/operators/onnx__LeakyRelu.html#leakyrelu-6 "Online Documentation")
542
+
543
+
544
+ LeakyRelu takes input data (Tensor<T>) and an argument alpha, and produces one
545
+ output data (Tensor<T>) where the function `f(x) = alpha * x for x < 0`,
546
+ `f(x) = x for x >= 0`, is applied to the data tensor elementwise.
547
+
548
+
549
+ Args:
550
+ X: (differentiable) Input tensor
551
+
552
+ alpha: Coefficient of leakage.
553
+ """
554
+
555
+ schema = get_schema("LeakyRelu", 6, "")
556
+ op = Op(self, "LeakyRelu", schema)
557
+ return op(*self._prepare_inputs(schema, X), alpha=alpha)
558
+
559
+ T_Log = TypeVar("T_Log", DOUBLE, FLOAT, FLOAT16)
560
+
561
+ def Log(self, input: T_Log) -> T_Log:
562
+ r"""[🌐 Log(6)](https://onnx.ai/onnx/operators/onnx__Log.html#log-6 "Online Documentation")
563
+
564
+
565
+ Calculates the natural log of the given input tensor, element-wise.
566
+
567
+
568
+ Args:
569
+ input: Input tensor
570
+ """
571
+
572
+ schema = get_schema("Log", 6, "")
573
+ op = Op(self, "Log", schema)
574
+ return op(*self._prepare_inputs(schema, input))
575
+
576
+ T_Max = TypeVar("T_Max", DOUBLE, FLOAT, FLOAT16)
577
+
578
+ def Max(self, *data_0: T_Max) -> T_Max:
579
+ r"""[🌐 Max(6)](https://onnx.ai/onnx/operators/onnx__Max.html#max-6 "Online Documentation")
580
+
581
+
582
+ Element-wise max of each of the input tensors. All inputs and outputs must
583
+ have the same shape and data type.
584
+
585
+
586
+ Args:
587
+ data_0: (variadic) List of tensors for Max.
588
+ """
589
+
590
+ schema = get_schema("Max", 6, "")
591
+ op = Op(self, "Max", schema)
592
+ return op(*self._prepare_inputs(schema, *data_0))
593
+
594
+ T_Mean = TypeVar("T_Mean", DOUBLE, FLOAT, FLOAT16)
595
+
596
+ def Mean(self, *data_0: T_Mean) -> T_Mean:
597
+ r"""[🌐 Mean(6)](https://onnx.ai/onnx/operators/onnx__Mean.html#mean-6 "Online Documentation")
598
+
599
+
600
+ Element-wise mean of each of the input tensors. All inputs and outputs must
601
+ have the same shape and data type.
602
+
603
+
604
+ Args:
605
+ data_0: (variadic) List of tensors for Mean.
606
+ """
607
+
608
+ schema = get_schema("Mean", 6, "")
609
+ op = Op(self, "Mean", schema)
610
+ return op(*self._prepare_inputs(schema, *data_0))
611
+
612
+ T_Min = TypeVar("T_Min", DOUBLE, FLOAT, FLOAT16)
613
+
614
+ def Min(self, *data_0: T_Min) -> T_Min:
615
+ r"""[🌐 Min(6)](https://onnx.ai/onnx/operators/onnx__Min.html#min-6 "Online Documentation")
616
+
617
+
618
+ Element-wise min of each of the input tensors. All inputs and outputs must
619
+ have the same shape and data type.
620
+
621
+
622
+ Args:
623
+ data_0: (variadic) List of tensors for Min
624
+ """
625
+
626
+ schema = get_schema("Min", 6, "")
627
+ op = Op(self, "Min", schema)
628
+ return op(*self._prepare_inputs(schema, *data_0))
629
+
630
+ T_Mul = TypeVar("T_Mul", DOUBLE, FLOAT, FLOAT16, INT32, INT64, UINT32, UINT64)
631
+
632
+ def Mul(
633
+ self, A: T_Mul, B: T_Mul, *, axis: Optional[int] = None, broadcast: int = 0
634
+ ) -> T_Mul:
635
+ r"""[🌐 Mul(6)](https://onnx.ai/onnx/operators/onnx__Mul.html#mul-6 "Online Documentation")
636
+
637
+
638
+ Performs element-wise binary multiplication (with limited broadcast support).
639
+
640
+ If necessary the right-hand-side argument will be broadcasted to match the
641
+ shape of left-hand-side argument. When broadcasting is specified, the second
642
+ tensor can either be of element size 1 (including a scalar tensor and any
643
+ tensor with rank equal to or smaller than the first tensor), or having its
644
+ shape as a contiguous subset of the first tensor's shape. The starting of the
645
+ mutually equal shape is specified by the argument "axis", and if it is not set,
646
+ suffix matching is assumed. 1-dim expansion doesn't work yet.
647
+
648
+ For example, the following tensor shapes are supported (with broadcast=1):
649
+
650
+ shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
651
+ shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
652
+ shape(A) = (2, 3, 4, 5), shape(B) = (5,)
653
+ shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
654
+ shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
655
+ shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0
656
+
657
+ Attribute `broadcast=1` needs to be passed to enable broadcasting.
658
+
659
+
660
+ Args:
661
+ A: First operand, should share the type with the second operand.
662
+
663
+ B: Second operand. With broadcasting can be of smaller size than A. If
664
+ broadcasting is disabled it should be of the same size.
665
+
666
+ axis: If set, defines the broadcast dimensions. See doc for details.
667
+
668
+ broadcast: Pass 1 to enable broadcasting
669
+ """
670
+
671
+ schema = get_schema("Mul", 6, "")
672
+ op = Op(self, "Mul", schema)
673
+ return op(*self._prepare_inputs(schema, A, B), axis=axis, broadcast=broadcast)
674
+
675
+ T_Neg = TypeVar("T_Neg", DOUBLE, FLOAT, FLOAT16, INT16, INT32, INT64, INT8)
676
+
677
+ def Neg(self, X: T_Neg) -> T_Neg:
678
+ r"""[🌐 Neg(6)](https://onnx.ai/onnx/operators/onnx__Neg.html#neg-6 "Online Documentation")
679
+
680
+
681
+ Neg takes one input data (Tensor<T>) and produces one output data
682
+ (Tensor<T>) where each element flipped sign, y = -x, is applied to
683
+ the tensor elementwise.
684
+
685
+
686
+ Args:
687
+ X: Input tensor
688
+ """
689
+
690
+ schema = get_schema("Neg", 6, "")
691
+ op = Op(self, "Neg", schema)
692
+ return op(*self._prepare_inputs(schema, X))
693
+
694
+ T_PRelu = TypeVar("T_PRelu", DOUBLE, FLOAT, FLOAT16)
695
+
696
+ def PRelu(self, X: T_PRelu, slope: T_PRelu) -> T_PRelu:
697
+ r"""[🌐 PRelu(6)](https://onnx.ai/onnx/operators/onnx__PRelu.html#prelu-6 "Online Documentation")
698
+
699
+
700
+
701
+ PRelu takes input data (Tensor<T>) and slope tensor as input, and produces one
702
+ output data (Tensor<T>) where the function `f(x) = slope * x for x < 0`,
703
+ `f(x) = x for x >= 0`., is applied to the data tensor elementwise.
704
+
705
+
706
+
707
+ Args:
708
+ X: Input tensor
709
+
710
+ slope: Slope tensor. If `Slope` is of size 1, the value is sharedacross
711
+ different channels
712
+ """
713
+
714
+ schema = get_schema("PRelu", 6, "")
715
+ op = Op(self, "PRelu", schema)
716
+ return op(*self._prepare_inputs(schema, X, slope))
717
+
718
+ T_Reciprocal = TypeVar("T_Reciprocal", DOUBLE, FLOAT, FLOAT16)
719
+
720
+ def Reciprocal(self, X: T_Reciprocal) -> T_Reciprocal:
721
+ r"""[🌐 Reciprocal(6)](https://onnx.ai/onnx/operators/onnx__Reciprocal.html#reciprocal-6 "Online Documentation")
722
+
723
+
724
+ Reciprocal takes one input data (Tensor<T>) and produces one output data
725
+ (Tensor<T>) where the reciprocal is, y = 1/x, is applied to
726
+ the tensor elementwise.
727
+
728
+
729
+ Args:
730
+ X: Input tensor
731
+ """
732
+
733
+ schema = get_schema("Reciprocal", 6, "")
734
+ op = Op(self, "Reciprocal", schema)
735
+ return op(*self._prepare_inputs(schema, X))
736
+
737
+ T_Relu = TypeVar("T_Relu", DOUBLE, FLOAT, FLOAT16)
738
+
739
+ def Relu(self, X: T_Relu) -> T_Relu:
740
+ r"""[🌐 Relu(6)](https://onnx.ai/onnx/operators/onnx__Relu.html#relu-6 "Online Documentation")
741
+
742
+
743
+ Relu takes one input data (Tensor<T>) and produces one output data
744
+ (Tensor<T>) where the rectified linear function, y = max(0, x), is applied to
745
+ the tensor elementwise.
746
+
747
+
748
+ Args:
749
+ X: Input tensor
750
+ """
751
+
752
+ schema = get_schema("Relu", 6, "")
753
+ op = Op(self, "Relu", schema)
754
+ return op(*self._prepare_inputs(schema, X))
755
+
756
+ T_Selu = TypeVar("T_Selu", DOUBLE, FLOAT, FLOAT16)
757
+
758
+ def Selu(
759
+ self,
760
+ X: T_Selu,
761
+ *,
762
+ alpha: float = 1.6732631921768188,
763
+ gamma: float = 1.0507010221481323,
764
+ ) -> T_Selu:
765
+ r"""[🌐 Selu(6)](https://onnx.ai/onnx/operators/onnx__Selu.html#selu-6 "Online Documentation")
766
+
767
+
768
+ Selu takes one input data (Tensor<T>) and produces one output data
769
+ (Tensor<T>) where the scaled exponential linear unit function,
770
+ `y = gamma * (alpha * e^x - alpha) for x <= 0`, `y = gamma * x for x > 0`,
771
+ is applied to the tensor elementwise.
772
+
773
+
774
+ Args:
775
+ X: (differentiable) Input tensor
776
+
777
+ alpha: Coefficient of SELU default to 1.67326319217681884765625 (i.e.,
778
+ float32 approximation of 1.6732632423543772848170429916717).
779
+
780
+ gamma: Coefficient of SELU default to 1.05070102214813232421875 (i.e.,
781
+ float32 approximation of 1.0507009873554804934193349852946).
782
+ """
783
+
784
+ schema = get_schema("Selu", 6, "")
785
+ op = Op(self, "Selu", schema)
786
+ return op(*self._prepare_inputs(schema, X), alpha=alpha, gamma=gamma)
787
+
788
+ T_Sigmoid = TypeVar("T_Sigmoid", DOUBLE, FLOAT, FLOAT16)
789
+
790
+ def Sigmoid(self, X: T_Sigmoid) -> T_Sigmoid:
791
+ r"""[🌐 Sigmoid(6)](https://onnx.ai/onnx/operators/onnx__Sigmoid.html#sigmoid-6 "Online Documentation")
792
+
793
+
794
+ Sigmoid takes one input data (Tensor<T>) and produces one output data
795
+ (Tensor<T>) where the sigmoid function, y = 1 / (1 + exp(-x)), is applied to the
796
+ tensor elementwise.
797
+
798
+
799
+ Args:
800
+ X: Input tensor
801
+ """
802
+
803
+ schema = get_schema("Sigmoid", 6, "")
804
+ op = Op(self, "Sigmoid", schema)
805
+ return op(*self._prepare_inputs(schema, X))
806
+
807
+ T_Sqrt = TypeVar("T_Sqrt", DOUBLE, FLOAT, FLOAT16)
808
+
809
+ def Sqrt(self, X: T_Sqrt) -> T_Sqrt:
810
+ r"""[🌐 Sqrt(6)](https://onnx.ai/onnx/operators/onnx__Sqrt.html#sqrt-6 "Online Documentation")
811
+
812
+
813
+ Square root takes one input data (Tensor<T>) and produces one output data
814
+ (Tensor<T>) where the square root is, y = x^0.5, is applied to
815
+ the tensor elementwise. If x is negative, then it will return NaN.
816
+
817
+
818
+ Args:
819
+ X: Input tensor
820
+ """
821
+
822
+ schema = get_schema("Sqrt", 6, "")
823
+ op = Op(self, "Sqrt", schema)
824
+ return op(*self._prepare_inputs(schema, X))
825
+
826
+ T_Sub = TypeVar("T_Sub", DOUBLE, FLOAT, FLOAT16, INT32, INT64, UINT32, UINT64)
827
+
828
+ def Sub(
829
+ self, A: T_Sub, B: T_Sub, *, axis: Optional[int] = None, broadcast: int = 0
830
+ ) -> T_Sub:
831
+ r"""[🌐 Sub(6)](https://onnx.ai/onnx/operators/onnx__Sub.html#sub-6 "Online Documentation")
832
+
833
+
834
+ Performs element-wise binary subtraction (with limited broadcast support).
835
+
836
+ If necessary the right-hand-side argument will be broadcasted to match the
837
+ shape of left-hand-side argument. When broadcasting is specified, the second
838
+ tensor can either be of element size 1 (including a scalar tensor and any
839
+ tensor with rank equal to or smaller than the first tensor), or having its
840
+ shape as a contiguous subset of the first tensor's shape. The starting of the
841
+ mutually equal shape is specified by the argument "axis", and if it is not set,
842
+ suffix matching is assumed. 1-dim expansion doesn't work yet.
843
+
844
+ For example, the following tensor shapes are supported (with broadcast=1):
845
+
846
+ shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
847
+ shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
848
+ shape(A) = (2, 3, 4, 5), shape(B) = (5,)
849
+ shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
850
+ shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
851
+ shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0
852
+
853
+ Attribute `broadcast=1` needs to be passed to enable broadcasting.
854
+
855
+
856
+ Args:
857
+ A: First operand, should share the type with the second operand.
858
+
859
+ B: Second operand. With broadcasting can be of smaller size than A. If
860
+ broadcasting is disabled it should be of the same size.
861
+
862
+ axis: If set, defines the broadcast dimensions. See doc for details.
863
+
864
+ broadcast: Pass 1 to enable broadcasting
865
+ """
866
+
867
+ schema = get_schema("Sub", 6, "")
868
+ op = Op(self, "Sub", schema)
869
+ return op(*self._prepare_inputs(schema, A, B), axis=axis, broadcast=broadcast)
870
+
871
+ T_Sum = TypeVar("T_Sum", DOUBLE, FLOAT, FLOAT16)
872
+
873
+ def Sum(self, *data_0: T_Sum) -> T_Sum:
874
+ r"""[🌐 Sum(6)](https://onnx.ai/onnx/operators/onnx__Sum.html#sum-6 "Online Documentation")
875
+
876
+
877
+ Element-wise sum of each of the input tensors. All inputs and outputs must
878
+ have the same shape and data type.
879
+
880
+
881
+ Args:
882
+ data_0: (variadic) List of tensors for Sum.
883
+ """
884
+
885
+ schema = get_schema("Sum", 6, "")
886
+ op = Op(self, "Sum", schema)
887
+ return op(*self._prepare_inputs(schema, *data_0))
888
+
889
+ T_Tanh = TypeVar("T_Tanh", DOUBLE, FLOAT, FLOAT16)
890
+
891
+ def Tanh(self, input: T_Tanh) -> T_Tanh:
892
+ r"""[🌐 Tanh(6)](https://onnx.ai/onnx/operators/onnx__Tanh.html#tanh-6 "Online Documentation")
893
+
894
+
895
+ Calculates the hyperbolic tangent of the given input tensor element-wise.
896
+
897
+
898
+ Args:
899
+ input: Input tensor
900
+ """
901
+
902
+ schema = get_schema("Tanh", 6, "")
903
+ op = Op(self, "Tanh", schema)
904
+ return op(*self._prepare_inputs(schema, input))
905
+
906
+ T_Tile = TypeVar(
907
+ "T_Tile",
908
+ BOOL,
909
+ COMPLEX128,
910
+ COMPLEX64,
911
+ DOUBLE,
912
+ FLOAT,
913
+ FLOAT16,
914
+ INT16,
915
+ INT32,
916
+ INT64,
917
+ INT8,
918
+ STRING,
919
+ UINT16,
920
+ UINT32,
921
+ UINT64,
922
+ UINT8,
923
+ )
924
+
925
+ T1_Tile: TypeAlias = INT64
926
+
927
+ def Tile(self, input: T_Tile, repeats: T1_Tile) -> T_Tile:
928
+ r"""[🌐 Tile(6)](https://onnx.ai/onnx/operators/onnx__Tile.html#tile-6 "Online Documentation")
929
+
930
+ Constructs a tensor by tiling a given tensor.
931
+ This is the same as function `tile` in Numpy, but no broadcast.
932
+ For example A = [[1, 2], [3, 4]], B = [1, 2], tile(A, B) = [[1, 2, 1, 2], [3, 4, 3, 4]]
933
+
934
+
935
+ Args:
936
+ input: Input tensor of any shape.
937
+
938
+ repeats: 1D int64 tensor of the same length as input's dimension number,
939
+ includes numbers of repeated copies along input's dimensions.
940
+ """
941
+
942
+ schema = get_schema("Tile", 6, "")
943
+ op = Op(self, "Tile", schema)
944
+ return op(*self._prepare_inputs(schema, input, repeats))