Skip to content

Commit c53b8f3

Browse files
committed
Update emit ordering
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
1 parent 2c43e9a commit c53b8f3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

onnxscript/_converter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,14 @@ def _to_onnx_var(
331331
# promote attribute to value
332332
result = self._generate_unique_name(target)
333333
attr = _to_onnx_ref_attr(val, info)
334-
self.emit("Constant", [], [result], [attr])
334+
self.emit([], "Constant", [result], [attr])
335335
if ta.base_type_is_bool(val.typeinfo):
336336
# ONNX attributes use an int-encoding for bools, but ONNX tensor types
337337
# distinguish between int and bool. So we cast the int tensor to a bool tensor,
338338
# to promote a (python) bool attribute to a ONNX bool tensor.
339339
result_as_bool = self._generate_unique_name(result + "_as_bool")
340340
self.emit(
341-
"Cast", [result], [result_as_bool], [ir.AttrInt64("to", ir.DataType.BOOL)]
341+
[result], "Cast", [result_as_bool], [ir.AttrInt64("to", ir.DataType.BOOL)]
342342
)
343343
return Variable(result_as_bool, castable=True)
344344
return Variable(result, castable=True)
@@ -355,9 +355,9 @@ def _py_var_to_onnx_var(self, py_var: str, info: sourceinfo.SourceInfo) -> Varia
355355

356356
def emit(
357357
self,
358+
outputs: Sequence[str],
358359
op_type: str,
359360
inputs: Sequence[str],
360-
outputs: Sequence[str],
361361
attrs: Sequence[ir.Attr] = (),
362362
domain: str = "",
363363
):
@@ -396,13 +396,13 @@ def _emit_const(
396396
except Exception as e:
397397
fail(info.msg(str(e)))
398398

399-
self.emit("Constant", [], [var_name], [ir.AttrTensor("value", tensor)])
399+
self.emit([], "Constant", [var_name], [ir.AttrTensor("value", tensor)])
400400
return Variable(var_name, True)
401401

402402
def _emit_copy(self, original_var: str, suggested_name: str) -> str:
403403
"""Emits a copy statement, using the ONNX Identity operator."""
404404
new_var = self._generate_unique_name(suggested_name)
405-
self.emit("Identity", [original_var], [new_var])
405+
self.emit([original_var], "Identity", [new_var])
406406
return new_var
407407

408408
def _eval_constant_expr(self, expr: ast.AST) -> PyValue:
@@ -1082,8 +1082,8 @@ def rename(x):
10821082
if renamed == [test]:
10831083
self.fail(stmt, f"Input and output cannot be the same {renamed!r}.")
10841084
self.emit(
1085-
"If",
10861085
[test],
1086+
"If",
10871087
renamed,
10881088
[then_attr, else_attr],
10891089
)

0 commit comments

Comments
 (0)