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

Lei Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 21 09:48:42 PST 2020


antiagainst added inline comments.


================
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>
----------------
denis13 wrote:
> mravishankar wrote:
> > 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.
> @mravishankar thanks for review, I took those tests from structure-ops.mlir and linearize the type in same way as it works for memref, memref<2x3xf32> -> !spv.ptr<!spv.struct<!spv,array<6xf32>>>. I'll update according your suggestion. Thanks!
This does not seem to address Mahesh's comment about linearizing the tensor literal itself? (It should be easy given that the data blob remains the same; we just need to call `DenseElementsAttr::reshape()` on it.) We'll need a test case for n-D tensors. :)


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