[PATCH] D73022: [mlir][spirv] Add lowering for composite constant.

Mahesh Ravishankar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 20 11:40:57 PST 2020


mravishankar added inline comments.


================
Comment at: mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp:194
+  auto compositeType =
+      constCompositeOp.getResult().getType().dyn_cast<TensorType>();
+  if (!compositeType) {
----------------
Why not use RankedTensorType. 


================
Comment at: mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir:225
+  %5 = constant dense<1> : tensor<2x3xi32>
+  // CHECK: spv.constant dense<1.000000e+00> : tensor<2x3xf32> : !spv.array<6 x f32 [4]>
+  %6 = constant dense<1.0> : tensor<2x3xf32>
----------------
Having the constant be a `tensor<2x3xi32>` while the result is a `!spv.array<6 x i32>` is weird. To a great extent this is an artifact of the way constants are stored in MLIR, but we should probably linearize the constant to be a `tensor<6xi32>` to make it less weird.


================
Comment at: mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir:227
+  %6 = constant dense<1.0> : tensor<2x3xf32>
+  // CHECK: spv.constant dense<{{\[}}[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32> : !spv.array<6 x i32 [4]>
+  %7 = constant dense<[[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32>
----------------
Same as above. We probably need to linearize the constant attribute to a `tensor<6xi32>`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73022/new/

https://reviews.llvm.org/D73022





More information about the llvm-commits mailing list