File tree 2 files changed +26
-4
lines changed
2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -906,10 +906,15 @@ class FrontendGenImpl {
906
906
std::vector<NamedAttribute> attributes;
907
907
for (int i = 0 ; i < node.attribute_size (); ++i) {
908
908
auto attr = node.attribute (i);
909
- auto mlir_type = convertONNXTypeToMLIRType (
910
- builder_, static_cast <onnx::TensorProto_DataType>(attr.i ()));
911
- Attribute mlirAttr = TypeAttr::get (mlir_type);
912
- attributes.push_back (builder_.getNamedAttr (attr.name (), mlirAttr));
909
+ if (attr.name () == " to" ) {
910
+ auto mlir_type = convertONNXTypeToMLIRType (
911
+ builder_, static_cast <onnx::TensorProto_DataType>(attr.i ()));
912
+ Attribute mlirAttr = TypeAttr::get (mlir_type);
913
+ attributes.push_back (builder_.getNamedAttr (attr.name (), mlirAttr));
914
+ } else {
915
+ NamedAttribute na = convertOnnxAttributeProtoToMlirNamedAttribute (attr);
916
+ attributes.push_back (na);
917
+ }
913
918
}
914
919
915
920
// If the node has a name, then import it.
Original file line number Diff line number Diff line change
1
+ // RUN: onnx-mlir --EmitONNXBasic --printIR %s | FileCheck %s
2
+
3
+ <
4
+ ir_version: 7,
5
+ opset_import: ["" : 19],
6
+ producer_name: "backend-test"
7
+ >
8
+ test_cast (int64[1] x) => (float[1] y) {
9
+ y = Cast<saturate = 0, to = 1>(x)
10
+ }
11
+
12
+ // CHECK-LABEL: func.func @main_graph
13
+ // CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<1xi64> {onnx.name = "x"}) -> (tensor<1xf32> {onnx.name = "y"}) {
14
+ // CHECK: [[VAR_0_:%.+]] = "onnx.Cast"([[PARAM_0_]]) {saturate = 0 : si64, to = f32} : (tensor<1xi64>) -> tensor<1xf32>
15
+ // CHECK: onnx.Return [[VAR_0_]] : tensor<1xf32>
16
+ // CHECK: }
17
+ // CHECK: "onnx.EntryPoint"() {func = @main_graph} : () -> ()
You can’t perform that action at this time.
0 commit comments