Skip to content

Commit

Permalink
add boilerplate for graph attribute type
Browse files Browse the repository at this point in the history
  • Loading branch information
Xida Ren committed Jan 30, 2024
1 parent b363158 commit 5fd7053
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python/torch_mlir/extras/onnx_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,12 @@ def tensor_proto_to_attr(self, tp: onnx.TensorProto) -> Attribute:
# Ommitted: STRING,
}

def graph_attribute_handler(attr: onnx.AttributeProto, cc: ContextCache) -> Attribute:
"""Handles a Graph attribute."""
print(dir(attr))
print(cc)
raise OnnxImportError("Graph attributes not supported yet")

# Mapping of AttributeType code to one of:
# None: Ignore attribute and do not output to MLIR
# False: Error if an attribute of this type is present
Expand All @@ -618,7 +624,7 @@ def tensor_proto_to_attr(self, tp: onnx.TensorProto) -> Attribute:
onnx.AttributeProto.AttributeType.TENSOR: lambda a, cc: cc.tensor_proto_to_attr(
a.t
),
onnx.AttributeProto.AttributeType.GRAPH: False,
onnx.AttributeProto.AttributeType.GRAPH: graph_attribute_handler,
onnx.AttributeProto.AttributeType.SPARSE_TENSOR: False,
onnx.AttributeProto.AttributeType.TYPE_PROTO: False,
onnx.AttributeProto.AttributeType.FLOATS: lambda a, cc: ArrayAttr.get(
Expand Down

0 comments on commit 5fd7053

Please sign in to comment.