MHLO operations that have regions use a zero-rank tensor to represent what are really scalar values. For example
func @reduce_one_op_all_locs_same(%arg0: tensor<?x?xf32>, %arg1 : tensor<f32>) -> (tensor<?xf32>) {
%0 = "mhlo.reduce"(%arg0, %arg1) ( {
^bb0(%arg2: tensor<f32> loc("foo"), %arg3: tensor<f32> loc("foo")):
%1 = "mhlo.add"(%arg2, %arg3) : (tensor<f32>, tensor<f32>) -> tensor<f32> loc("foo")
"mhlo.return"(%1) : (tensor<f32>) -> () loc("foo")
}) {dimensions = dense<[1]> : tensor<1xi64>} : (tensor<?x?xf32>, tensor<f32>) -> tensor<?xf32> loc("foo")
return %0: tensor<?xf32>
}
There are a couple of issues here.
MHLO operations that have regions use a zero-rank tensor to represent what are really scalar values. For example
There are a couple of issues here.
mhlo.reducehere has anmhlo.add. The way one would lowermhlo.addto saylinalgdialect is very different whether this operation is within anmhloop or at the top level. This seems to be a conflation between different uses of anmhlo.addoperation. It would be much easier to handle this ifmhlo.addwas only used at the top level and a different operation was used withinmhlooperations.mhlooperation in this case seems to be a sequence of computations that are really scalars. Using tensor of zero rank introduces additional complexity when translating this toLinalgdialect since this requires a type conversion of the arguments from zero rank tensor to scalars. Having this scalar before the conversion would reduce a lot of the complexity.