Skip to content

Commit 0834bec

Browse files
committed
Use ir.Attr value
Signed-off-by: Ganesan Ramalingam <[email protected]>
1 parent 8c6084c commit 0834bec

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

onnxscript/_internal/converter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def _to_onnx_attr_ref(
354354
msg = f"Unsupported attribute type {pytype!r}."
355355
fail(info.msg(msg) if info else msg)
356356
attr_type = ir.AttributeType(ta.pytype_to_attrtype(pytype))
357-
return ir.Attr(attrname, attr_type, None, val.value)
357+
return ir.Attr(attrname, attr_type, None, val.value.name)
358358

359359
def _to_onnx_var(
360360
self,
@@ -536,7 +536,7 @@ def _translate_attr(
536536
val = self._lookup(expr.id, self._source_of(expr))
537537
if isinstance(val, values.AttrRef):
538538
attr_type = ir.AttributeType(ta.pytype_to_attrtype(val.typeinfo))
539-
attr_ref = ir.Attr(attr_name, attr_type, None, val.value)
539+
attr_ref = ir.Attr(attr_name, attr_type, None, val.value.name)
540540
if attr_meta is not None and (attr_ref.type != attr_meta.type):
541541
self.fail(
542542
expr,
@@ -1459,7 +1459,7 @@ def _translate_function_signature_common(
14591459
attribute_type = ta.pytype_to_attrtype(typeinfo)
14601460
attr = ir.Attr(x.arg, ir.AttributeType(attribute_type), default_value, None)
14611461
self._current_fn.append_parameter(attr)
1462-
self._bind(x.arg, values.AttrRef(x.arg, typeinfo, self._source_of(x)))
1462+
self._bind(x.arg, values.AttrRef(attr, typeinfo, self._source_of(x)))
14631463
else:
14641464
onnx_parameter = make_value(x.arg, typeinfo, self._source_of(x))
14651465
self._current_fn.append_parameter(onnx_parameter)

onnxscript/_internal/values.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,18 +861,18 @@ def __init__(self, info: sourceinfo.SourceInfo) -> None:
861861

862862
class AttrRef(SymbolValue):
863863
def __init__(
864-
self, attr_name: str, typeinfo: _GenericAlias, info: sourceinfo.SourceInfo
864+
self, attr: ir.Attr, typeinfo: _GenericAlias, info: sourceinfo.SourceInfo
865865
) -> None:
866866
"""Initializes AttrRef.
867867
868868
Arguments:
869-
attr_name: name of the attribute-parameter
869+
attr: An ir.Attr representing the attribute-parameter
870870
typeinfo: type annotation of the attribute.
871871
op's attributes in ONNX are usually single type or list of single type.
872872
info: for debugging use.
873873
"""
874874
super().__init__(info)
875-
self.value = attr_name
875+
self.value = attr
876876
self.typeinfo = typeinfo
877877
if not isinstance(typeinfo, (type, _GenericAlias)):
878878
# typing._GenericAlias for List[int] and List[str], etc.

0 commit comments

Comments
 (0)