Repository navigation
Closed
Description
Describe the bug
This is derived from python integration tests. We can not compile it through Linalg on tensors path because of incompatible casting: error: 'memref.cast' op operand type 'memref<2x2x3xf32, affine_map<(d0, d1, d2) -> (d0 * 24 + d1 * 3 + d2)>>' and result type 'memref<2x2x3xf32>' are cast incompatible
Full log with print-ir-after-all: https://gist.github.com/hanhanW/e6379ccb49734d02fbec72a812898a09
To Reproduce
Input:
module {
flow.variable @"__iree_flow___sm_node10__models.0.layer-1.kernel" dense<[[[-0.13618423, -0.192097351], [0.0231686831, 0.0401024222], [-0.0545493364, 0.201520681], [-0.00443521142, 0.326102138], [0.128793389, -0.245250553], [0.137357265, 0.106325984]], [[0.047303021, -0.0885396301], [-0.0520330071, 0.0851422846], [0.270904183, 0.105822921], [0.2183097, -0.272363394], [-0.144181311, -0.31716451], [0.14819628, 0.173835874]], [[0.117750376, 0.0214254856], [0.167927891, -0.296281904], [-2.943510e-01, 0.164804757], [-0.214259773, -0.123117313], [-0.136577874, -0.261526048], [-0.218869865, 0.176537275]], [[0.0560905635, 0.315549374], [0.271571755, -0.234585106], [-0.263455212, 0.0695755481], [-0.210849702, 0.0118177831], [0.31562233, -0.21225217], [-0.29745391, 0.0638558566]], [[0.041213274, 0.199718058], [0.0549429059, -0.25981468], [0.291258335, -0.142322928], [0.0345993936, -0.144354567], [-0.275278687, -0.072343111], [-0.281624347, -0.299874336]], [[0.277506769, 0.245634913], [-0.0209748745, -0.0196942091], [0.0836308598, 1.507180e-01], [0.284812868, -0.0930951089], [-0.192198485, 0.067567557], [-0.0643128753, 0.0577070415]], [[0.241745412, 0.208432674], [-0.322542399, -0.169554397], [-0.195777908, -0.300730854], [0.312929451, -0.215913534], [0.129433542, 0.154974908], [0.224668384, 0.154421121]]]> : tensor<7x6x2xf32> attributes {sym_visibility = "private"}
flow.variable @"__iree_flow___sm_node11__models.0.layer-1.bias" dense<0.000000e+00> : tensor<7x2xf32> attributes {sym_visibility = "private"}
func @LocallyConnected1D__2x8x3__f32__uniform__filters_2__kernel_size_2__strides_1__padding_valid__implementation_1(%arg0: tensor<2x8x3xf32> {tf._user_specified_name = "args_0"}) -> tensor<2x7x2xf32> attributes {iree.module.export, iree.reflection = {abi = "sip", abiv = 1 : i32, sip = "I8!S5!k0_0R3!_0"}, tf._construction_context = "kEagerRuntime", tf._input_shapes = [#tf.shape<2x8x3>, #tf.shape<>, #tf.shape<>], tf.signature.is_stateful} {
%0 = flow.variable.address @"__iree_flow___sm_node10__models.0.layer-1.kernel" : !iree.ptr<tensor<7x6x2xf32>>
%1 = flow.variable.address @"__iree_flow___sm_node11__models.0.layer-1.bias" : !iree.ptr<tensor<7x2xf32>>
%2 = "mhlo.slice"(%arg0) {limit_indices = dense<[2, 2, 3]> : tensor<3xi64>, start_indices = dense<0> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>} : (tensor<2x8x3xf32>) -> tensor<2x2x3xf32>
%3 = "mhlo.reshape"(%2) : (tensor<2x2x3xf32>) -> tensor<1x2x6xf32>
%4 = "mhlo.slice"(%arg0) {limit_indices = dense<[2, 3, 3]> : tensor<3xi64>, start_indices = dense<[0, 1, 0]> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>} : (tensor<2x8x3xf32>) -> tensor<2x2x3xf32>
%5 = "mhlo.reshape"(%4) : (tensor<2x2x3xf32>) -> tensor<1x2x6xf32>
%6 = "mhlo.slice"(%arg0) {limit_indices = dense<[2, 4, 3]> : tensor<3xi64>, start_indices = dense<[0, 2, 0]> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>} : (tensor<2x8x3xf32>) -> tensor<2x2x3xf32>
%7 = "mhlo.reshape"(%6) : (tensor<2x2x3xf32>) -> tensor<1x2x6xf32>
%8 = "mhlo.slice"(%arg0) {limit_indices = dense<[2, 5, 3]> : tensor<3xi64>, start_indices = dense<[0, 3, 0]> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>} : (tensor<2x8x3xf32>) -> tensor<2x2x3xf32>
%9 = "mhlo.reshape"(%8) : (tensor<2x2x3xf32>) -> tensor<1x2x6xf32>
%10 = "mhlo.slice"(%arg0) {limit_indices = dense<[2, 6, 3]> : tensor<3xi64>, start_indices = dense<[0, 4, 0]> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>} : (tensor<2x8x3xf32>) -> tensor<2x2x3xf32>
%11 = "mhlo.reshape"(%10) : (tensor<2x2x3xf32>) -> tensor<1x2x6xf32>
%12 = "mhlo.slice"(%arg0) {limit_indices = dense<[2, 7, 3]> : tensor<3xi64>, start_indices = dense<[0, 5, 0]> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>} : (tensor<2x8x3xf32>) -> tensor<2x2x3xf32>
%13 = "mhlo.reshape"(%12) : (tensor<2x2x3xf32>) -> tensor<1x2x6xf32>
%14 = "mhlo.slice"(%arg0) {limit_indices = dense<[2, 8, 3]> : tensor<3xi64>, start_indices = dense<[0, 6, 0]> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>} : (tensor<2x8x3xf32>) -> tensor<2x2x3xf32>
%15 = "mhlo.reshape"(%14) : (tensor<2x2x3xf32>) -> tensor<1x2x6xf32>
%16 = "mhlo.concatenate"(%3, %5, %7, %9, %11, %13, %15) {dimension = 0 : i64} : (tensor<1x2x6xf32>, tensor<1x2x6xf32>, tensor<1x2x6xf32>, tensor<1x2x6xf32>, tensor<1x2x6xf32>, tensor<1x2x6xf32>, tensor<1x2x6xf32>) -> tensor<7x2x6xf32>
%17 = flow.variable.load.indirect %0 : !iree.ptr<tensor<7x6x2xf32>> -> tensor<7x6x2xf32>
%18 = "mhlo.dot_general"(%16, %17) {dot_dimension_numbers = {lhs_batching_dimensions = dense<0> : tensor<1xi64>, lhs_contracting_dimensions = dense<2> : tensor<1xi64>, rhs_batching_dimensions = dense<0> : tensor<1xi64>, rhs_contracting_dimensions = dense<1> : tensor<1xi64>}} : (tensor<7x2x6xf32>, tensor<7x6x2xf32>) -> tensor<7x2x2xf32>
%19 = "mhlo.transpose"(%18) {permutation = dense<[1, 0, 2]> : tensor<3xi64>} : (tensor<7x2x2xf32>) -> tensor<2x7x2xf32>
%20 = flow.variable.load.indirect %1 : !iree.ptr<tensor<7x2xf32>> -> tensor<7x2xf32>
%21 = "mhlo.reshape"(%20) : (tensor<7x2xf32>) -> tensor<1x7x2xf32>
%22 = "mhlo.broadcast_in_dim"(%21) {broadcast_dimensions = dense<[0, 1, 2]> : tensor<3xi64>} : (tensor<1x7x2xf32>) -> tensor<2x7x2xf32>
%23 = mhlo.add %19, %22 : tensor<2x7x2xf32>
return %23 : tensor<2x7x2xf32>
}
}Run iree-translate --iree-mlir-to-vm-bytecode-module --iree-hal-target-backends=vulkan-spirv -iree-flow-dispatch-linalg-on-tensors=true -iree-codegen-spirv-experimental-linalg-on-tensors=true LocallyConnected1D.mlir
Activity
MaheshRavishankar commentedon Apr 5, 2021
PR #5259 should help here. It will be a few days before it will land though.
Set IREE codegen to Linalg on tensors by default.
MaheshRavishankar commentedon Apr 9, 2021
As part of this work PR #5392 (which reworks PR #5259 after
flow.tensor.reshapewas made a tied op) is needed. This hits an issue of getting a segfault in the Flow to HAL conversion. This repros the issueOriginal error here : https://gist.github.com/MaheshRavishankar/71dae2d98c41839610d7db1cb804ee8e
Set IREE codegen to Linalg on tensors by default.
Set IREE codegen to Linalg on tensors by default. (#5375)
MaheshRavishankar commentedon Apr 27, 2021
Fixed by dbd43a7