Created
February 7, 2023 03:26
-
-
Save AmosLewis/2890afedc18b40f2860fc9605bf272e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func.func @torch.aten.broadcast_to(%arg0: !torch.vtensor<[1,1,1,128],i1>) -> !torch.vtensor<[1,1,128,128],i1> { | |
%int1 = torch.constant.int 1 | |
%int128 = torch.constant.int 128 | |
%1 = torch.prim.ListConstruct %int1, %int1, %int128, %int128 : (!torch.int, !torch.int, !torch.int, !torch.int) -> !torch.list<int> | |
%0 = torch.aten.broadcast_to %arg0, %1 : !torch.vtensor<[1,1,1,128],i1>, !torch.list<int> -> !torch.vtensor<[1,1,128,128],i1> | |
return %0 : !torch.vtensor<[1,1,128,128],i1> | |
} |
func.func @torch.aten.broadcast_to(%arg0: !torch.vtensor<[1,1,1,128],i1>) -> !torch.vtensor<[1,1,128,256],i1> {
%int1 = torch.constant.int 1
%int128 = torch.constant.int 128
%int256 = torch.constant.int 256
%1 = torch.prim.ListConstruct %int1, %int1, %int128, %int256 : (!torch.int, !torch.int, !torch.int, !torch.int) -> !torch.list<int>
%0 = torch.aten.broadcast_to %arg0, %1 : !torch.vtensor<[1,1,1,128],i1>, !torch.list<int> -> !torch.vtensor<[1,1,128,256],i1>
return %0 : !torch.vtensor<[1,1,128,256],i1>
}
// CHECK-LABEL: func.func @torch.aten.broadcast_to(
// CHECK-SAME: %[[VAL_0:.*]]: !torch.vtensor<[1,1,1,128],i1>) -> !torch.vtensor<[1,1,128,128],i1> {
// CHECK: %[[VAL_1:.*]] = torch_c.to_builtin_tensor %[[VAL_0]] : !torch.vtensor<[1,1,1,128],i1> -> tensor<1x1x1x128xi1>
// CHECK: %[[VAL_2:.*]] = torch.constant.int 1
// CHECK: %[[VAL_3:.*]] = torch.constant.int 128
// CHECK: %[[VAL_4:.*]] = torch.prim.ListConstruct %[[VAL_2]], %[[VAL_2]], %[[VAL_3]], %[[VAL_3]] : (!torch.int, !torch.int, !torch.int, !torch.int) -> !torch.list<int>
// CHECK: %[[VAL_5:.*]] = "tosa.const"() {value = dense<0> : tensor<1x1x128x1xi64>} : () -> tensor<1x1x128x1xi64>
// CHECK: %[[VAL_6:.*]] = "tosa.add"(%[[VAL_1]], %[[VAL_5]]) : (tensor<1x1x1x128xi1>, tensor<1x1x128x1xi64>) -> tensor<1x1x128x128xi1>
// CHECK: %[[VAL_7:.*]] = torch_c.from_builtin_tensor %[[VAL_6]] : tensor<1x1x128x128xi1> -> !torch.vtensor<[1,1,128,128],i1>
// CHECK: return %[[VAL_7]] : !torch.vtensor<[1,1,128,128],i1>
// CHECK: }
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
** Insert : 'torch_c.to_builtin_tensor'(0x55dd1bb42610)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::detail::PreservedAnalyses::AllAnalysesType)
/tmp/broadcast_to.mlir:6:3: error: type of return operand 0 ('!torch.vtensor<[1,1,1,128],i1>') doesn't match function result type ('!torch.vtensor<[1,1,128,128],i1>') in function @torch.aten.broadcast_to
return %0 : !torch.vtensor<[1,1,128,128],i1>
^
/tmp/broadcast_to.mlir:6:3: note: see current operation: "func.return"(%arg0) : (!torch.vtensor<[1,1,1,128],i1>) -> ()
// -----// IR Dump After ConvertTorchToTosa Failed (convert-torch-to-tosa) //----- //
mlir-asm-printer: Verifying operation: func.func
type of return operand 0 ('!torch.vtensor<[1,1,1,128],i1>') doesn't match function result type ('!torch.vtensor<[1,1,128,128],i1>') in function @torch.aten.broadcast_to
mlir-asm-printer: 'func.func' failed to verify and will be printed in generic form
"func.func"() ({
^bb0(%arg0: !torch.vtensor<[1,1,1,128],i1>):
%0 = "torch_c.to_builtin_tensor"(%arg0) : (!torch.vtensor<[1,1,1,128],i1>) -> tensor<1x1x1x128xi1>
%1 = "torch.constant.int"() {value = 1 : i64} : () -> !torch.int
%2 = "torch.constant.int"() {value = 128 : i64} : () -> !torch.int
%3 = "torch.prim.ListConstruct"(%1, %1, %2, %2) : (!torch.int, !torch.int, !torch.int, !torch.int) -> !torch.list
"func.return"(%arg0) : (!torch.vtensor<[1,1,1,128],i1>) -> ()
}) {function_type = (!torch.vtensor<[1,1,1,128],i1>) -> !torch.vtensor<[1,1,128,128],i1>, sym_name = "torch.aten.broadcast_to"} : () -> ()