Skip to content

Commit c7d1eb5

Browse files
committed
ir builder cleanup
Signed-off-by: Ganesan Ramalingam <[email protected]>
1 parent e0281a3 commit c7d1eb5

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

onnxscript/converter.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def tensor_name_generator() -> str:
299299
proto = autocast.pyvalue_to_onnx_attribute(
300300
attrname, attrval, tensor_name_generator, attrtype
301301
)
302-
return self.ir_builder.make_attr(proto)
302+
return ir.from_proto(proto)
303303

304304
def _to_onnx_attr_ref(
305305
self, val: values.AttrRef, info: Optional[sourceinfo.SourceInfo]
@@ -318,7 +318,8 @@ def _to_onnx_attr_ref(
318318
else:
319319
msg = f"Unsupported attribute type {pytype!r}."
320320
fail(info.msg(msg) if info else msg)
321-
return self.ir_builder.make_attr_ref(attrname, val.value, pytype)
321+
attr_type = ir.AttributeType(ta.pytype_to_attrtype(pytype))
322+
return ir.Attr(attrname, attr_type, None, val.value)
322323

323324
def _to_onnx_var(
324325
self,
@@ -492,7 +493,8 @@ def _translate_attr(
492493
if isinstance(expr, ast.Name):
493494
val = self._lookup(expr.id, self._source_of(expr))
494495
if isinstance(val, values.AttrRef):
495-
attr_ref = self.ir_builder.make_attr_ref(attr_name, val.value, val.typeinfo)
496+
attr_type = ir.AttributeType(ta.pytype_to_attrtype(val.typeinfo))
497+
attr_ref = ir.Attr(attr_name, attr_type, None, val.value)
496498
if attr_meta is not None and (attr_ref.type != attr_meta.type):
497499
self.fail(
498500
expr,

onnxscript/irbuilder.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,3 @@ def add_attr_parameter(
197197

198198
def add_output(self, fn: IRFunction, varname: str, typeinfo, sourceinfo) -> None:
199199
fn.append_output(_make_value(varname, typeinfo, sourceinfo))
200-
201-
def make_attr(self, attrproto: onnx.AttributeProto) -> ir.Attr:
202-
return ir.from_proto(attrproto)
203-
204-
def make_attr_ref(self, attrname: str, refname: str, pytype: type) -> ir.Attr:
205-
attr_type = ir.AttributeType(onnxscript.type_annotation.pytype_to_attrtype(pytype))
206-
return ir.Attr(attrname, attr_type, None, refname)

0 commit comments

Comments
 (0)