From fb095564386e656688c88fe7ac128bfdc117ce0e Mon Sep 17 00:00:00 2001 From: Sunny Anand <164108690+Sunny-Anand@users.noreply.github.com> Date: Tue, 3 Dec 2024 11:43:21 -0600 Subject: [PATCH 1/4] Fix security vulenrabilities (#3019) * Fix security vulenraibilities in requirements.txt for mnist example- CVE-2024-28219 pillow - CVE-2024-48063 torch package - CVE-2024-31584 CVE-2024-31583 CVE-2024-31580 for torch package Signed-off-by: Sunny Anand * upgrade torchvision to match torch Signed-off-by: Sunny Anand --------- Signed-off-by: Sunny Anand --- docs/mnist_example/requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/mnist_example/requirements.txt b/docs/mnist_example/requirements.txt index fe023b5220..4d01c849b1 100644 --- a/docs/mnist_example/requirements.txt +++ b/docs/mnist_example/requirements.txt @@ -1,4 +1,4 @@ numpy~=1.22.2 -pillow~=10.2.0 -torch~=2.0.0 -torchvision~=0.15.1 +pillow~=10.3.0 +torch~=2.5.0 +torchvision~=0.20.0 From bac09ee8a11a632952864bc0cdd12b32c6ec91da Mon Sep 17 00:00:00 2001 From: Jonas Rickert Date: Wed, 4 Dec 2024 03:42:57 +0100 Subject: [PATCH 2/4] Do not fuse locations when normalizing constants for Add and Mul (#3016) Signed-off-by: Rickert, Jonas --- src/Dialect/ONNX/Transforms/ConstProp.td | 8 +++--- test/mlir/onnx/onnx_constprop_locations.mlir | 30 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 test/mlir/onnx/onnx_constprop_locations.mlir diff --git a/src/Dialect/ONNX/Transforms/ConstProp.td b/src/Dialect/ONNX/Transforms/ConstProp.td index 1baef13dad..408d01464e 100644 --- a/src/Dialect/ONNX/Transforms/ConstProp.td +++ b/src/Dialect/ONNX/Transforms/ConstProp.td @@ -302,9 +302,9 @@ def CreateScatterNDOfConst : // Use commutativity to normalize constants in the second position of Add. def AddConstCommutative1 : NamedPat<"AddConstCommutative1", // From add(c, x). - (ONNXAddOp (ONNXConstantOp:$c $_, $_, $_, $_, $_, $_, $_, $_), $x), + (ONNXAddOp:$addOp (ONNXConstantOp:$c $_, $_, $_, $_, $_, $_, $_, $_), $x), // To add(x, c). - (ONNXAddOp $x, $c), + (ONNXAddOp $x, $c, (location $addOp)), // To avoid infinite loop, constrain the first arguments to be anything but a constant. [(IsNotAConstant:$x)]>; @@ -575,9 +575,9 @@ def SumConstProp : NamedPat<"SumConstProp", // Use commutativity to normalize constants in the second position of Mul. def MulConstCommutative1 : NamedPat<"MulConstCommutative1", // From mul(c, x). - (ONNXMulOp (ONNXConstantOp:$c $_, $_, $_, $_, $_, $_, $_, $_), $x), + (ONNXMulOp:$mulOp (ONNXConstantOp:$c $_, $_, $_, $_, $_, $_, $_, $_), $x), // To mul(x, c). - (ONNXMulOp $x, $c), + (ONNXMulOp $x, $c, (location $mulOp)), // To avoid infinite loop, constrain the first arguments to be anything but a constant. [(IsNotAConstant:$x)]>; diff --git a/test/mlir/onnx/onnx_constprop_locations.mlir b/test/mlir/onnx/onnx_constprop_locations.mlir new file mode 100644 index 0000000000..c4124ca182 --- /dev/null +++ b/test/mlir/onnx/onnx_constprop_locations.mlir @@ -0,0 +1,30 @@ +// RUN: onnx-mlir-opt --shape-inference --constprop-onnx %s -split-input-file --mlir-print-debuginfo | FileCheck %s + + +//===----------------------------------------------------------------------===// +/// Commutative tests + +// CHECK-LABEL: @test_add_constant_1_loc +func.func @test_add_constant_1_loc(%arg0 : tensor<3xf32>) -> tensor<3xf32> { + %0 = onnx.Constant dense<[0.0, 1.0, 2.0]> : tensor<3xf32> loc("Constant") + %1 = "onnx.Add"(%0, %arg0) : (tensor<3xf32> , tensor<3xf32>) -> tensor<3xf32> loc("Add") + "onnx.Return"(%1) : (tensor<3xf32>) -> () + // CHECK-NEXT: [[CONST:%.+]] = onnx.Constant dense<[0.000000e+00, 1.000000e+00, 2.000000e+00]> : tensor<3xf32> loc([[LOC_CONST:#.+]]) + // CHECK-NEXT: [[ADD:%.+]] = "onnx.Add"(%arg0, [[CONST]]) : (tensor<3xf32>, tensor<3xf32>) -> tensor<3xf32> loc([[LOC_ADD:#.+]]) + // CHECK-DAG: [[LOC_CONST]] = loc("Constant") + // CHECK-DAG: [[LOC_ADD]] = loc("Add") +} + +// ----- + +// CHECK-LABEL: @test_mul_constant_1_loc +func.func @test_mul_constant_1_loc(%arg0 : tensor<3xf32>) -> tensor<3xf32> { + %0 = onnx.Constant dense<[0.0, 1.0, 2.0]> : tensor<3xf32> loc("Constant") + %1 = "onnx.Mul"(%0, %arg0) : (tensor<3xf32> , tensor<3xf32>) -> tensor<3xf32> loc("Mul") + "onnx.Return"(%1) : (tensor<3xf32>) -> () + // CHECK-NEXT: [[CONST:%.+]] = onnx.Constant dense<[0.000000e+00, 1.000000e+00, 2.000000e+00]> : tensor<3xf32> loc([[LOC_CONST:#.+]]) + // CHECK-NEXT: [[MUL:%.+]] = "onnx.Mul"(%arg0, [[CONST]]) : (tensor<3xf32>, tensor<3xf32>) -> tensor<3xf32> loc([[LOC_MUL:#.+]]) + // CHECK-DAG: [[LOC_CONST]] = loc("Constant") + // CHECK-DAG: [[LOC_MUL]] = loc("Mul") +} + From 40f501760ed65b0ae7f503847ed74b2a7b5807de Mon Sep 17 00:00:00 2001 From: "Tung D. Le" Date: Wed, 4 Dec 2024 13:48:48 +0900 Subject: [PATCH 3/4] Handle full reduction over all dimensions (#3022) Signed-off-by: Tung D. Le --- src/Conversion/ONNXToKrnl/Math/Reduction.cpp | 12 +++ .../Math/Reduction_with_canonicalize_O3.mlir | 41 ++++++++++ ...duction_with_parallel_canonicalize_O3.mlir | 79 +++++++++++++++++++ 3 files changed, 132 insertions(+) diff --git a/src/Conversion/ONNXToKrnl/Math/Reduction.cpp b/src/Conversion/ONNXToKrnl/Math/Reduction.cpp index 2e3892324e..34336d1030 100644 --- a/src/Conversion/ONNXToKrnl/Math/Reduction.cpp +++ b/src/Conversion/ONNXToKrnl/Math/Reduction.cpp @@ -662,6 +662,18 @@ struct ONNXReductionOpLowering : public OpConversionPattern { } } + ////////////////////////////////////////////////////////////////////// + // Reduction over all dimensions to a scalar value. + bool fullReduction = hasNoAxes || (rawAxesIE.size() == inRank); + if (fullReduction && !isKeepdims && enableSIMD) { + Value alloc, none; + if (emitFullSIMDReductionFor( + rewriter, loc, op, input, alloc, none, enableParallel)) { + rewriter.replaceOp(op, alloc); + return success(); + } + } + ////////////////////////////////////////////////////////////////////// // Characterize literal axes: make unique and within [0, inRank). std::vector uniqueLitAxes; diff --git a/test/mlir/conversion/onnx_to_krnl/Math/Reduction_with_canonicalize_O3.mlir b/test/mlir/conversion/onnx_to_krnl/Math/Reduction_with_canonicalize_O3.mlir index 9a18e44b77..82d5e441e5 100644 --- a/test/mlir/conversion/onnx_to_krnl/Math/Reduction_with_canonicalize_O3.mlir +++ b/test/mlir/conversion/onnx_to_krnl/Math/Reduction_with_canonicalize_O3.mlir @@ -40,6 +40,47 @@ func.func @test_reduce_scalar_axes(%arg0: tensor) -> tensor // ----- +// COM: Full reduction over all dimensions to a scalar value. +func.func @test_reduce_all_to_scalar(%arg0: tensor) -> tensor<*xf32> { + %axes = "onnx.NoValue"() {value} : () -> none + %0 = "onnx.ReduceMax"(%arg0, %axes) {keepdims = 0 : si64, noop_with_empty_axes = 0 : si64} : (tensor, none) -> tensor<*xf32> + return %0: tensor<*xf32> + +// CHECK-DAG: [[MAP_0_:#.+]] = affine_map<()[s0] -> (s0 * 64)> +// CHECK-LABEL: func.func @test_reduce_all_to_scalar +// CHECK-SAME: ([[PARAM_0_:%.+]]: memref) -> memref { +// CHECK-DAG: [[VAR_cst_:%.+]] = arith.constant dense<0xFF800000> : vector<32xf32> +// CHECK-DAG: [[CST_2_:%.+]] = arith.constant 2 : index +// CHECK-DAG: [[CST_0_:%.+]] = arith.constant 0 : index +// CHECK-NOT: separator of consecutive DAGs +// CHECK-DAG: [[VAR_dim_:%.+]] = memref.dim [[PARAM_0_]], [[CST_0_]] : memref +// CHECK-DAG: [[VAR_dim_0_:%.+]] = memref.dim [[PARAM_0_]], [[CST_2_]] : memref +// CHECK: [[VAR_0_:%.+]] = affine.apply [[MAP_0_]](){{.}}[[VAR_dim_]]{{.}} +// CHECK-DAG: [[VAR_1_:%.+]] = arith.muli [[VAR_0_]], [[VAR_dim_0_]] : index +// CHECK-DAG: [[RES_:%.+]] = memref.alloc() {{.*}}: memref<1xindex> +// CHECK: affine.store [[VAR_1_]], [[RES_]][0] : memref<1xindex> +// CHECK-DAG: [[VAR_reshape_:%.+]] = memref.reshape [[PARAM_0_]]([[RES_]]) : (memref, memref<1xindex>) -> memref +// CHECK-DAG: [[RES_1_:%.+]] = memref.alloc() {{.*}}: memref<32xf32> +// CHECK-DAG: [[RES_2_:%.+]] = memref.alloc() : memref +// CHECK: vector.store [[VAR_cst_]], [[RES_1_]]{{.}}[[CST_0_]]{{.}} : memref<32xf32>, vector<32xf32> +// CHECK: [[LOOP_0_:%.+]] = krnl.define_loops 1 +// CHECK: [[BLOCK_TILE__0_:%.+]], [[BLOCK_IN__0_:%.+]] = krnl.block [[LOOP_0_]] 32 : (!krnl.loop) -> (!krnl.loop, !krnl.loop) +// CHECK: krnl.iterate([[BLOCK_TILE__0_]]) with ([[LOOP_0_]] -> [[I_0_:%.+]] = 0 to [[VAR_1_]]){ +// CHECK: [[VAR_5_:%.+]] = krnl.get_induction_var_value([[BLOCK_TILE__0_]]) : (!krnl.loop) -> index +// CHECK-DAG: [[LOAD_VAR_reshape_MEM_:%.+]] = vector.load [[VAR_reshape_]]{{.}}[[VAR_5_]]{{.}} : memref, vector<32xf32> +// CHECK-DAG: [[LOAD_RES_1_MEM_:%.+]] = vector.load [[RES_1_]]{{.}}[[CST_0_]]{{.}} : memref<32xf32>, vector<32xf32> +// CHECK: [[VAR_8_:%.+]] = arith.maxnumf [[LOAD_RES_1_MEM_]], [[LOAD_VAR_reshape_MEM_]] : vector<32xf32> +// CHECK: vector.store [[VAR_8_]], [[RES_1_]]{{.}}[[CST_0_]]{{.}} : memref<32xf32>, vector<32xf32> +// CHECK: } +// CHECK: [[LOAD_RES_1_MEM_1_:%.+]] = vector.load [[RES_1_]]{{.}}[[CST_0_]]{{.}} : memref<32xf32>, vector<32xf32> +// CHECK: [[VAR_4_:%.+]] = vector.reduction , [[LOAD_RES_1_MEM_1_]] : vector<32xf32> into f32 +// CHECK: krnl.store [[VAR_4_]], [[RES_2_]][] : memref +// CHECK: return [[RES_2_]] : memref +// CHECK: } +} + +// ----- + func.func private @test_reducemax_v13(%arg0 : tensor<3x2x2xf32>) -> tensor<*xf32> { %0 ="onnx.ReduceMaxV13"(%arg0) {axes=[1], keepdims = 0 : si64} : (tensor<3x2x2xf32>)-> tensor<*xf32> "func.return"(%0) : (tensor<*xf32>) -> () diff --git a/test/mlir/conversion/onnx_to_krnl/Math/Reduction_with_parallel_canonicalize_O3.mlir b/test/mlir/conversion/onnx_to_krnl/Math/Reduction_with_parallel_canonicalize_O3.mlir index 7290d34032..b2cc41276c 100644 --- a/test/mlir/conversion/onnx_to_krnl/Math/Reduction_with_parallel_canonicalize_O3.mlir +++ b/test/mlir/conversion/onnx_to_krnl/Math/Reduction_with_parallel_canonicalize_O3.mlir @@ -2,6 +2,85 @@ // ----- +// COM: Full reduction over all dimensions to a scalar value. +func.func @test_reduce_all_to_scalar(%arg0: tensor) -> tensor<*xf32> { + %axes = "onnx.NoValue"() {value} : () -> none + %0 = "onnx.ReduceMax"(%arg0, %axes) {keepdims = 0 : si64, noop_with_empty_axes = 0 : si64} : (tensor, none) -> tensor<*xf32> + return %0: tensor<*xf32> + +// CHECK-DAG: [[MAP_0_:#.+]] = affine_map<()[s0] -> (s0 * 64)> +// CHECK-DAG: [[MAP_1_:#.+]] = affine_map<(d0) -> (d0 * 32)> +// CHECK-LABEL: func.func @test_reduce_all_to_scalar +// CHECK-SAME: ([[PARAM_0_:%.+]]: memref) -> memref { +// CHECK-DAG: [[VAR_cst_:%.+]] = arith.constant dense<0xFF800000> : vector<1xf32> +// CHECK-DAG: [[VAR_cst_0_:%.+]] = arith.constant dense<0xFF800000> : vector<32xf32> +// CHECK-DAG: [[CST_31_:%.+]] = arith.constant 31 : index +// CHECK-DAG: [[CST_32_:%.+]] = arith.constant 32 : index +// CHECK-DAG: [[CST_8_:%.+]] = arith.constant 8 : index +// CHECK-DAG: [[CST_1_:%.+]] = arith.constant 1 : index +// CHECK-DAG: [[CST_2_:%.+]] = arith.constant 2 : index +// CHECK-DAG: [[CST_0_:%.+]] = arith.constant 0 : index +// CHECK-NOT: separator of consecutive DAGs +// CHECK-DAG: [[VAR_dim_:%.+]] = memref.dim [[PARAM_0_]], [[CST_0_]] : memref +// CHECK-DAG: [[VAR_dim_1_:%.+]] = memref.dim [[PARAM_0_]], [[CST_2_]] : memref +// CHECK: [[VAR_0_:%.+]] = affine.apply [[MAP_0_]](){{.}}[[VAR_dim_]]{{.}} +// CHECK-DAG: [[VAR_1_:%.+]] = arith.muli [[VAR_0_]], [[VAR_dim_1_]] : index +// CHECK-DAG: [[RES_:%.+]] = memref.alloc() {{.*}}: memref<1xindex> +// CHECK: affine.store [[VAR_1_]], [[RES_]][0] : memref<1xindex> +// CHECK-DAG: [[VAR_reshape_:%.+]] = memref.reshape [[PARAM_0_]]([[RES_]]) : (memref, memref<1xindex>) -> memref +// CHECK-DAG: [[RES_1_:%.+]] = memref.alloc() {{.*}}: memref<256xf32> +// CHECK-DAG: [[RES_2_:%.+]] = memref.alloc() : memref<8xf32> +// CHECK-DAG: [[VAR_2_:%.+]] = arith.ceildivsi [[VAR_1_]], [[CST_8_]] : index +// CHECK-DAG: [[LOOP_0_:%.+]] = krnl.define_loops 1 +// CHECK: krnl.parallel([[LOOP_0_]]) : !krnl.loop +// CHECK: krnl.iterate([[LOOP_0_]]) with ([[LOOP_0_]] -> [[I_0_:%.+]] = 0 to 8){ +// CHECK: [[VAR_7_:%.+]] = krnl.get_induction_var_value([[LOOP_0_]]) : (!krnl.loop) -> index +// CHECK: [[VAR_8_:%.+]] = arith.muli [[VAR_7_]], [[VAR_2_]] : index +// CHECK: [[VAR_9_:%.+]] = arith.addi [[VAR_8_]], [[VAR_2_]] : index +// CHECK: [[VAR_10_:%.+]] = arith.cmpi slt, [[VAR_1_]], [[VAR_9_]] : index +// CHECK-DAG: [[VAR_11_:%.+]] = arith.select [[VAR_10_]], [[VAR_1_]], [[VAR_9_]] : index +// CHECK-DAG: [[VAR_12_:%.+]] = affine.apply [[MAP_1_]]([[VAR_7_]]) +// CHECK: vector.store [[VAR_cst_0_]], [[RES_1_]]{{.}}[[VAR_12_]]{{.}} : memref<256xf32>, vector<32xf32> +// CHECK: [[VAR_13_:%.+]] = arith.subi [[VAR_11_]], [[CST_31_]] : index +// CHECK: scf.for [[I_1_:%.+]] = [[VAR_8_]] to [[VAR_13_]] step [[CST_32_]] { +// CHECK-DAG: [[LOAD_VAR_reshape_MEM_:%.+]] = vector.load [[VAR_reshape_]]{{.}}[[I_1_]]{{.}} : memref, vector<32xf32> +// CHECK-DAG: [[LOAD_RES_1_MEM_:%.+]] = vector.load [[RES_1_]]{{.}}[[VAR_12_]]{{.}} : memref<256xf32>, vector<32xf32> +// CHECK: [[VAR_22_:%.+]] = arith.maxnumf [[LOAD_RES_1_MEM_]], [[LOAD_VAR_reshape_MEM_]] : vector<32xf32> +// CHECK: vector.store [[VAR_22_]], [[RES_1_]]{{.}}[[VAR_12_]]{{.}} : memref<256xf32>, vector<32xf32> +// CHECK: } +// CHECK: [[VAR_14_:%.+]] = arith.subi [[VAR_11_]], [[VAR_8_]] : index +// CHECK: [[VAR_15_:%.+]] = arith.remsi [[VAR_14_]], [[CST_32_]] : index +// CHECK: [[VAR_16_:%.+]] = arith.subi [[VAR_14_]], [[VAR_15_]] : index +// CHECK: [[VAR_17_:%.+]] = arith.addi [[VAR_8_]], [[VAR_16_]] : index +// CHECK: scf.for [[I_2_:%.+]] = [[VAR_17_]] to [[VAR_11_]] step [[CST_1_]] { +// CHECK-DAG: [[LOAD_VAR_reshape_MEM_1_:%.+]] = memref.load [[VAR_reshape_]]{{.}}[[I_2_]]{{.}} : memref +// CHECK-DAG: [[LOAD_RES_1_MEM_1_:%.+]] = memref.load [[RES_1_]]{{.}}[[VAR_12_]]{{.}} : memref<256xf32> +// CHECK: [[VAR_22_1_:%.+]] = arith.maxnumf [[LOAD_RES_1_MEM_1_]], [[LOAD_VAR_reshape_MEM_1_]] : f32 +// CHECK: memref.store [[VAR_22_1_]], [[RES_1_]]{{.}}[[VAR_12_]]{{.}} : memref<256xf32> +// CHECK: } +// CHECK: [[LOAD_RES_1_MEM_2_:%.+]] = vector.load [[RES_1_]]{{.}}[[VAR_12_]]{{.}} : memref<256xf32>, vector<32xf32> +// CHECK: [[VAR_19_:%.+]] = vector.reduction , [[LOAD_RES_1_MEM_2_]] : vector<32xf32> into f32 +// CHECK: memref.store [[VAR_19_]], [[RES_2_]]{{.}}[[VAR_7_]]{{.}} : memref<8xf32> +// CHECK: } +// CHECK: [[RES_3_:%.+]] = memref.alloc() : memref +// CHECK: vector.store [[VAR_cst_]], [[RES_1_]]{{.}}[[CST_0_]]{{.}} : memref<256xf32>, vector<1xf32> +// CHECK: [[LOOP_1_:%.+]] = krnl.define_loops 1 +// CHECK: krnl.iterate([[LOOP_1_]]) with ([[LOOP_1_]] -> [[I_3_:%.+]] = 0 to 8){ +// CHECK: [[VAR_7_1_:%.+]] = krnl.get_induction_var_value([[LOOP_1_]]) : (!krnl.loop) -> index +// CHECK-DAG: [[VAR_8_1_:%.+]] = krnl.load [[RES_2_]]{{.}}[[VAR_7_1_]]{{.}} : memref<8xf32> +// CHECK-DAG: [[LOAD_RES_1_MEM_3_:%.+]] = krnl.load [[RES_1_]]{{.}}[[CST_0_]]{{.}} : memref<256xf32> +// CHECK: [[VAR_10_1_:%.+]] = arith.maxnumf [[LOAD_RES_1_MEM_3_]], [[VAR_8_1_]] : f32 +// CHECK: krnl.store [[VAR_10_1_]], [[RES_1_]]{{.}}[[CST_0_]]{{.}} : memref<256xf32> +// CHECK: } +// CHECK: [[LOAD_RES_1_MEM_4_:%.+]] = vector.load [[RES_1_]]{{.}}[[CST_0_]]{{.}} : memref<256xf32>, vector<1xf32> +// CHECK: [[VAR_6_:%.+]] = vector.extract [[LOAD_RES_1_MEM_4_]][0] : f32 from vector<1xf32> +// CHECK: krnl.store [[VAR_6_]], [[RES_3_]][] : memref +// CHECK: return [[RES_3_]] : memref +// CHECK: } +} + +// ----- + // With enable-parallel, a krnl.parallel should be created, which takes a loop (to be parallelized) // as input. The krnl.parallel should be the last operator before krnl.iterate, since the lowering // needs to interpret krnl.block, krnl.permute, krnl.unroll first. From f3fec68fde6df9623a109adc7cae0355a51dc0fe Mon Sep 17 00:00:00 2001 From: "Tung D. Le" Date: Wed, 4 Dec 2024 18:34:28 +0900 Subject: [PATCH 4/4] Use DisposableElementsAttr for ZHigh constant propagation (#3013) * Revert "[NNPA] Memory reduction of stickified constant by stickifying at file writing (#2917)" This reverts commit 33b466ecff0fcee7ff2b86a0ef257ff49463b2c3. Signed-off-by: Tung D. Le * Use DisposableElementsAttr for ZHigh Constant Propagation Signed-off-by: Tung D. Le --------- Signed-off-by: Tung D. Le --- src/Accelerators/NNPA/Compiler/CMakeLists.txt | 1 + .../NNPA/Compiler/NNPACompilerUtils.cpp | 14 +- .../ZHighDisposableGarbageCollector.cpp | 43 +++ .../ZHighDisposableGarbageCollector.hpp | 37 +++ .../ONNXToZHigh/ONNXToZHighCommon.cpp | 3 +- .../ONNXToZHigh/ONNXToZHighCommon.hpp | 5 +- .../Conversion/ZHighToZLow/ZHighToZLow.cpp | 159 ++++----- .../NNPA/Dialect/ZHigh/CMakeLists.txt | 1 - src/Accelerators/NNPA/Dialect/ZHigh/ZHigh.td | 5 +- .../NNPA/Dialect/ZHigh/ZHighOps/OpHelper.cpp | 51 +-- .../NNPA/Dialect/ZHigh/ZHighOps/OpHelper.hpp | 8 - .../NNPA/Dialect/ZLow/CMakeLists.txt | 5 - src/Accelerators/NNPA/Dialect/ZLow/ZLow.td | 17 - .../NNPA/Dialect/ZLow/ZLowOps.cpp | 77 ----- .../NNPA/Dialect/ZLow/ZLowOps.hpp | 2 - src/Accelerators/NNPA/Pass/NNPAPasses.hpp | 4 + .../NNPA/Transform/ZHigh/CMakeLists.txt | 17 +- .../Transform/ZHigh/ZHighConstPropagation.cpp | 305 +++++++++++++----- .../Transform/ZHigh/ZHighConstPropagation.td | 35 -- .../ZHigh/ZHighScrubDisposablePass.cpp | 64 ++++ .../ZLow/ZLowDummyOpForMultiDerefPass.cpp | 2 +- src/Compiler/CompilerPasses.cpp | 5 +- src/Conversion/KrnlToLLVM/CMakeLists.txt | 3 +- .../KrnlToLLVM/ConvertKrnlToLLVM.cpp | 63 ++-- .../KrnlToLLVM/ConvertKrnlToLLVM.hpp | 5 +- ...nlGlobalOpInterface.cpp => KrnlGlobal.cpp} | 172 +++++----- src/Conversion/ONNXToKrnl/Math/Reduction.cpp | 3 +- src/Dialect/Krnl/CMakeLists.txt | 1 - src/Dialect/Krnl/Krnl.td | 4 +- src/Dialect/Krnl/KrnlOps.cpp | 30 -- src/Dialect/Krnl/KrnlOps.hpp | 1 - .../ElementsAttr/DisposableElementsAttr.hpp | 22 +- src/Dialect/ONNX/ONNXOps/Canonicalize.cpp | 1 - src/Dialect/ONNX/ONNXOps/OpHelper.cpp | 24 -- src/Dialect/ONNX/ONNXOps/OpHelper.hpp | 3 - src/Interface/CMakeLists.txt | 12 - src/Interface/KrnlGlobalOpInterface.cpp | 24 -- src/Interface/KrnlGlobalOpInterface.hpp | 27 -- src/Interface/KrnlGlobalOpInterface.td | 88 ----- .../device-placement/emit-zhighir.mlir | 6 +- .../nnpa/conversion/lower-all-to-llvm.mlir | 1 - .../conversion/lower-to-llvm-be/lit.local.cfg | 6 - .../lower-all-to-llvm_be.mlir | 21 -- .../nnpa/conversion/zhigh-to-zlow/conv.mlir | 2 +- .../nnpa/conversion/zhigh-to-zlow/gru.mlir | 4 +- .../nnpa/conversion/zhigh-to-zlow/lstm.mlir | 4 +- .../zhigh-to-zlow/stickified-constant.mlir | 42 ++- test/mlir/accelerators/nnpa/driver/ccfd.mlir | 105 +++--- .../driver/dense-out-attention-layer.mlir | 2 +- .../constprop.mlir | 94 +++++- 50 files changed, 781 insertions(+), 849 deletions(-) create mode 100644 src/Accelerators/NNPA/Compiler/ZHighDisposableGarbageCollector.cpp create mode 100644 src/Accelerators/NNPA/Compiler/ZHighDisposableGarbageCollector.hpp create mode 100644 src/Accelerators/NNPA/Transform/ZHigh/ZHighScrubDisposablePass.cpp rename src/Conversion/KrnlToLLVM/{KrnlGlobalOpInterface.cpp => KrnlGlobal.cpp} (66%) delete mode 100644 src/Interface/KrnlGlobalOpInterface.cpp delete mode 100644 src/Interface/KrnlGlobalOpInterface.hpp delete mode 100644 src/Interface/KrnlGlobalOpInterface.td delete mode 100644 test/mlir/accelerators/nnpa/conversion/lower-to-llvm-be/lit.local.cfg delete mode 100644 test/mlir/accelerators/nnpa/conversion/lower-to-llvm-be/lower-all-to-llvm_be.mlir diff --git a/src/Accelerators/NNPA/Compiler/CMakeLists.txt b/src/Accelerators/NNPA/Compiler/CMakeLists.txt index 83e4bdd9a2..a12b9126d8 100644 --- a/src/Accelerators/NNPA/Compiler/CMakeLists.txt +++ b/src/Accelerators/NNPA/Compiler/CMakeLists.txt @@ -19,6 +19,7 @@ add_onnx_mlir_library(OMNNPACompilerOptions add_onnx_mlir_library(OMNNPACompilerUtils NNPACompilerUtils.cpp + ZHighDisposableGarbageCollector.cpp EXCLUDE_FROM_OM_LIBS diff --git a/src/Accelerators/NNPA/Compiler/NNPACompilerUtils.cpp b/src/Accelerators/NNPA/Compiler/NNPACompilerUtils.cpp index 2ba720859a..eefe6b9a15 100644 --- a/src/Accelerators/NNPA/Compiler/NNPACompilerUtils.cpp +++ b/src/Accelerators/NNPA/Compiler/NNPACompilerUtils.cpp @@ -32,6 +32,7 @@ #include "src/Accelerators/NNPA/Compiler/NNPACompilerOptions.hpp" #include "src/Accelerators/NNPA/Compiler/NNPACompilerUtils.hpp" +#include "src/Accelerators/NNPA/Compiler/ZHighDisposableGarbageCollector.hpp" #include "src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps.hpp" #include "src/Accelerators/NNPA/Dialect/ZLow/ZLowOps.hpp" #include "src/Accelerators/NNPA/Pass/NNPAPasses.hpp" @@ -120,10 +121,6 @@ void addONNXToZHighPasses(mlir::PassManager &pm) { pm.addNestedPass(onnx_mlir::createShapeInferencePass()); } - // Replace every DisposableElementsAttr with DenseElementsAttr. - // ZHighConstPropagation currently assumes that DenseElementsAttr is used. - pm.addPass(createScrubDisposablePass()); - // Experimental feature: Decompose stick/unstick into two phases: layout // transform and data conversion. Do some optimizations after decomposing. // Then, recompose again layout and data conversion if they are not optimized. @@ -146,8 +143,7 @@ void addONNXToZHighPasses(mlir::PassManager &pm) { // Only support BE machines. bool isBE = llvm::endianness::native == llvm::endianness::big; if (isBE) - pm.addNestedPass( - onnx_mlir::zhigh::createZHighConstPropagationPass()); + pm.addPass(onnx_mlir::zhigh::createZHighConstPropagationPass()); // Remove common sub-expressions. pm.addPass(mlir::createCSEPass()); @@ -155,6 +151,9 @@ void addONNXToZHighPasses(mlir::PassManager &pm) { // Clean dead code. pm.addPass(mlir::createSymbolDCEPass()); + // Replace every DisposableElementsAttr with DenseElementsAttr. + pm.addPass(onnx_mlir::zhigh::createZHighScrubDisposablePass()); + // Insert an instrumentation after lowering onnx to zhigh to get profiling // for onnx and zhigh ops. // Keep this pass at the end of this function. @@ -195,6 +194,9 @@ void addPassesNNPA(mlir::OwningOpRef &module, // LLVM_DEBUG(llvm::dbgs() << "Adding NNPA passes" << std::endl;); if (emissionTarget >= EmitONNXIR) { + pm.addInstrumentation( + std::make_unique( + pm.getContext())); addONNXToMLIRPasses(pm, /*target CPU*/ maccel.empty(), /*donotScrubDisposableElementsAttr*/ true); pm.addPass(onnx_mlir::createDevicePlacementPass(nnpaLoadDevicePlacementFile, diff --git a/src/Accelerators/NNPA/Compiler/ZHighDisposableGarbageCollector.cpp b/src/Accelerators/NNPA/Compiler/ZHighDisposableGarbageCollector.cpp new file mode 100644 index 0000000000..d5c1da2d3f --- /dev/null +++ b/src/Accelerators/NNPA/Compiler/ZHighDisposableGarbageCollector.cpp @@ -0,0 +1,43 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + */ + +//===---------------- ZHighDisposableGarbageCollector.cpp -----------------===// +// +// Garbage collects DisposableElementsAttr attributes. +// +//===----------------------------------------------------------------------===// + +#include "src/Accelerators/NNPA/Compiler/ZHighDisposableGarbageCollector.hpp" +#include "src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps.hpp" +#include "src/Dialect/ONNX/ElementsAttr/DisposablePool.hpp" +#include "src/Dialect/ONNX/ONNXDialect.hpp" +#include "src/Dialect/ONNX/ONNXOps.hpp" + +#include "mlir/IR/BuiltinOps.h" + +using namespace mlir; + +namespace onnx_mlir { +namespace zhigh { + +ZHighDisposableGarbageCollector::ZHighDisposableGarbageCollector( + MLIRContext *context) + : disposablePool(*DisposablePool::get(context)) {} + +ZHighDisposableGarbageCollector::~ZHighDisposableGarbageCollector() {} + +void ZHighDisposableGarbageCollector::runAfterPass(Pass *pass, Operation *op) { + if (!disposablePool.isActive()) + return; + ModuleOp moduleOp = mlir::dyn_cast(op); + if (!moduleOp) + return; + disposablePool.garbageCollectUnreachable( + moduleOp, {{ONNXConstantOp::getOperationName(), "value"}, + {ONNXConstantOfShapeOp::getOperationName(), "value"}, + {ZHighStickifiedConstantOp::getOperationName(), "value"}}); +} + +} // namespace zhigh +} // namespace onnx_mlir diff --git a/src/Accelerators/NNPA/Compiler/ZHighDisposableGarbageCollector.hpp b/src/Accelerators/NNPA/Compiler/ZHighDisposableGarbageCollector.hpp new file mode 100644 index 0000000000..c4a34d50eb --- /dev/null +++ b/src/Accelerators/NNPA/Compiler/ZHighDisposableGarbageCollector.hpp @@ -0,0 +1,37 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + */ + +//===---------------- ZHighDisposableGarbageCollector.hpp -----------------===// +// +// Garbage collects DisposableElementsAttr attributes. +// +//===----------------------------------------------------------------------===// + +#ifndef ONNX_MLIR_ZHIGH_GARBAGE_COLLECTOR_H +#define ONNX_MLIR_ZHIGH_GARBAGE_COLLECTOR_H + +#include "mlir/Pass/PassInstrumentation.h" + +namespace mlir { +class MLIRContext; +} + +namespace onnx_mlir { +class DisposablePool; + +namespace zhigh { + +struct ZHighDisposableGarbageCollector : public mlir::PassInstrumentation { + ZHighDisposableGarbageCollector(mlir::MLIRContext *context); + ~ZHighDisposableGarbageCollector() override; + + void runAfterPass(mlir::Pass *pass, mlir::Operation *op) override; + +private: + DisposablePool &disposablePool; +}; + +} // namespace zhigh +} // namespace onnx_mlir +#endif diff --git a/src/Accelerators/NNPA/Conversion/ONNXToZHigh/ONNXToZHighCommon.cpp b/src/Accelerators/NNPA/Conversion/ONNXToZHigh/ONNXToZHighCommon.cpp index 1a5c666f3b..ce7c4160bd 100644 --- a/src/Accelerators/NNPA/Conversion/ONNXToZHigh/ONNXToZHighCommon.cpp +++ b/src/Accelerators/NNPA/Conversion/ONNXToZHigh/ONNXToZHighCommon.cpp @@ -83,8 +83,7 @@ bool isF32ScalarConstantTensor(Value v) { FloatAttr getScalarF32AttrFromConstant(Value v) { if (!isF32ScalarConstantTensor(v)) return nullptr; - DenseElementsAttr constElements = ElementsAttrBuilder::toDenseElementsAttr( - getElementAttributeFromONNXValue(v)); + ElementsAttr constElements = getElementAttributeFromONNXValue(v); return constElements.getSplatValue(); } diff --git a/src/Accelerators/NNPA/Conversion/ONNXToZHigh/ONNXToZHighCommon.hpp b/src/Accelerators/NNPA/Conversion/ONNXToZHigh/ONNXToZHighCommon.hpp index e8e68a0e37..382d596e35 100644 --- a/src/Accelerators/NNPA/Conversion/ONNXToZHigh/ONNXToZHighCommon.hpp +++ b/src/Accelerators/NNPA/Conversion/ONNXToZHigh/ONNXToZHighCommon.hpp @@ -2,8 +2,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -//===---------- ONNXToZHighCommon.hpp - Common functions in ONNXToZHigh -//---------===// +//===---- ONNXToZHighCommon.hpp - Common functions in ONNXToZHigh ---------===// // // Copyright 2019-2024 The IBM Research Authors. // @@ -117,4 +116,4 @@ mlir::Value getDynShape( mlir::Location loc, mlir::PatternRewriter &rewriter, mlir::Value x); } // namespace onnx_mlir -#endif \ No newline at end of file +#endif diff --git a/src/Accelerators/NNPA/Conversion/ZHighToZLow/ZHighToZLow.cpp b/src/Accelerators/NNPA/Conversion/ZHighToZLow/ZHighToZLow.cpp index c3fca41393..20ba368893 100644 --- a/src/Accelerators/NNPA/Conversion/ZHighToZLow/ZHighToZLow.cpp +++ b/src/Accelerators/NNPA/Conversion/ZHighToZLow/ZHighToZLow.cpp @@ -168,6 +168,25 @@ static Value insertAllocForWorkAreaForRNNOps(IndexExprBuilderForKrnl &createIE, return create.mem.alignedAlloc(resultType, dims, gAlignment); } +/// Get a dense resource attribute to store stickified data of a given i8 value. +/// Attribute type: tensor +DenseResourceElementsAttr getDenseResourceElementsAttrOfValue( + PatternRewriter &rewriter, ZHighStickifiedConstantOp stickifiedConstant, + int8_t val, int64_t sizeInBytes) { + char *rawData = static_cast(malloc(sizeInBytes)); + assert(rawData && "failed to allocate memory for stickified data"); + memset(rawData, val, sizeInBytes); + DenseResourceElementsAttr valueAttr = DenseUI8ResourceElementsAttr::get( + RankedTensorType::get({sizeInBytes}, rewriter.getI8Type()), + stickifiedConstant.getOperation() + ->getDialect() + ->getNamespace(), // use the dialect as the blob "hint" + HeapAsmResourceBlob::allocateAndCopyWithAlign( + llvm::ArrayRef(rawData, sizeInBytes), alignof(char))); + free(rawData); + return valueAttr; +} + /// This function emits a buffer of zero elements for the given dimensions and /// layout. If the given dimensions are static, then a stickified constant is /// returned. @@ -190,48 +209,18 @@ Value insertAllocOrEmitZeroConstant(ArrayRef dims, affine::normalizeMemRefType(mlir::cast(zMemRefType.value)); // Create a ZHighStickifiedConstantOp. - - // Keep previous implementation about generating stickified data at - // ZHighConstPropagationPass. To use this, comment in and set directive " - // NNPA_ZHIGH_STICKIFIEDCONST_GEN" - // - // #ifdef NNPA_ZHIGH_STICKIFIEDCONST_GEN - // // Set zero in value attribute as DenseResourceElementsAttribute. - // ZHighStickifiedConstantOp stickifiedConstant = - // rewriter.create(loc, resType, - // /*stickified=*/rewriter.getBoolAttr(true), - // /*value=*/nullptr, - // /*alignment=*/rewriter.getI64IntegerAttr(4096)); - // - // // Use an dense resource attribute to store stickified data. - // // Attribute type: tensor - // int64_t sizeInBytes = - // affine::getIntOrFloatMemRefSizeInBytes(resType).value(); - // char *rawData = static_cast(malloc(sizeInBytes)); - // assert(rawData && "failed to allocate memory for stickified data"); - // memset(rawData, 0, sizeInBytes); - // DenseResourceElementsAttr valueAttr = - // DenseUI8ResourceElementsAttr::get( - // RankedTensorType::get({sizeInBytes}, rewriter.getI8Type()), - // stickifiedConstant.getOperation() - // ->getDialect() - // ->getNamespace(), // use the dialect as the blob "hint" - // HeapAsmResourceBlob::allocateAndCopyWithAlign( - // llvm::ArrayRef(rawData, sizeInBytes), alignof(char))); - // stickifiedConstant.setValueAttr(valueAttr); - // free(rawData); - // #else - - // Set zero in value attribute as SplatElementsAttr. - FloatAttr floatZero = rewriter.getFloatAttr(resType.getElementType(), 0.0); - ZHighStickifiedConstantOp stickifiedConstant = rewriter.create< - ZHighStickifiedConstantOp>(loc, resType, - /*stickified=*/rewriter.getBoolAttr(true), - /*value=*/SplatElementsAttr::get(cast(resType), floatZero), - /*alignment=*/rewriter.getI64IntegerAttr(4096)); - - // #endif // NNPA_ZHIGH_STICKIFIEDCONST_GEN - + ZHighStickifiedConstantOp stickifiedConstant = + rewriter.create(loc, resType, + /*value=*/nullptr, + /*alignment=*/rewriter.getI64IntegerAttr(4096)); + + // Use an dense resource attribute to store stickified data. + // Attribute type: tensor + int64_t sizeInBytes = + affine::getIntOrFloatMemRefSizeInBytes(resType).value(); + DenseResourceElementsAttr valueAttr = getDenseResourceElementsAttrOfValue( + rewriter, stickifiedConstant, 0, sizeInBytes); + stickifiedConstant.setValueAttr(valueAttr); res = stickifiedConstant.getResult(); } else { MultiDialectBuilder create(rewriter, loc); @@ -706,7 +695,7 @@ struct ZHighToZLowUnstickOpLowering : public ConversionPattern { }; //===----------------------------------------------------------------------===// -// Lower ZHigh Stickified Constant to ZLow Stickified Constant +// Lower ZHigh Stickified Constant to KrnlGlobal //===----------------------------------------------------------------------===// struct ZHighToZLowStickifiedConstantOpLowering : public ConversionPattern { @@ -719,7 +708,7 @@ struct ZHighToZLowStickifiedConstantOpLowering : public ConversionPattern { LogicalResult matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { Location loc = op->getLoc(); - ZHighStickifiedConstantOp zhighStickifiedConstOp = + ZHighStickifiedConstantOp stickifiedConstOp = llvm::dyn_cast(op); // Convert ZTensor type to MemRefType. @@ -733,59 +722,53 @@ struct ZHighToZLowStickifiedConstantOpLowering : public ConversionPattern { affine::normalizeMemRefType(mlir::cast(zMemRefType.value)); ArrayRef normalizedShape = normalizedType.getShape(); - // Create ZLowStickifiedConstantOp. - StringAttr layout = - getZTensorLayoutAttr(rewriter, *op->result_type_begin()); + // Validate the stickified tensor. + Attribute valueAttr = stickifiedConstOp.getValueAttr(); + int64_t sizeInBytes = getMemRefEltSizeInBytes(normalizedType); + sizeInBytes *= normalizedType.getNumElements(); + if (auto denseAttr = mlir::dyn_cast_or_null(valueAttr)) { + ArrayRef data = denseAttr.getRawData(); + if (denseAttr.isSplat()) { + // Constant ztensor's buffer is tensor. + int8_t v = denseAttr.getSplatValue(); + // NNPA does not work with a splat buffer. + // Expand the memory buffer for NNPA by using DenseResourceElementsAttr. + valueAttr = getDenseResourceElementsAttrOfValue( + rewriter, stickifiedConstOp, v, sizeInBytes); + } else { + assert( + (data.size() == static_cast(sizeInBytes)) && + "The stickified tensor's buffer size and MemRef's size mismatched"); + } + } else if (auto resourceAttr = + mlir::dyn_cast_or_null( + valueAttr)) { + auto blob = resourceAttr.getRawHandle().getBlob(); + assert(blob && "Expecting dense resource with a valid blob"); + ArrayRef data = blob->getData(); + assert( + (data.size() == static_cast(sizeInBytes)) && + "The stickified tensor's buffer size and MemRef's size mismatched"); + } else { + llvm_unreachable("Unsupported ElementsAttr"); + } - // Keep previous implementation about generating stickified data at - // ZHighConstPropagationPass. To use this, comment in and set directive " - // NNPA_ZHIGH_STICKIFIEDCONST_GEN" - // - // #ifdef NNPA_ZHIGH_STICKIFIEDCONST_GEN - // // Lower to KrnlGlobalOp - // // Get dense resource attribute. - // auto blob = mlir::cast( - // zhighStickifiedConstOp.getValue().value()) - // .getRawHandle() - // .getBlob(); - // assert(blob && "Expecting dense resource with a valid blob"); - // ArrayRef data = blob->getData(); - // // Validate the stickified tensor. - // int64_t memRefSizeInBytes = getMemRefEltSizeInBytes(normalizedType); - // memRefSizeInBytes *= normalizedType.getNumElements(); - // assert((data.size() == static_cast(memRefSizeInBytes)) && - // "The stickified tensor's buffer size and MemRef's size - // mismatched"); - // // Create a KrnlGlobalOp. - // KrnlGlobalOp constantOp = - // rewriter.create(loc, zMemRefType.value, - // /*shape=*/ - // rewriter.getI64ArrayAttr(normalizedShape), - // /*name=*/ - // rewriter.getStringAttr( - // "constant_stickify_" + std::to_string(constantID)), - // /*value=*/zhighStickifiedConstOp.getValueAttr(), - // /*offset=*/nullptr, - // /*alignment=*/zhighStickifiedConstOp.getAlignmentAttr()); - // #else - ZLowStickifiedConstantOp constantOp = - rewriter.create(loc, - mlir::cast(zMemRefType.value), + // Create a KrnlGlobalOp. + KrnlGlobalOp constantGlobal = + rewriter.create(loc, zMemRefType.value, /*shape=*/ rewriter.getI64ArrayAttr(normalizedShape), /*name=*/ rewriter.getStringAttr( "constant_stickify_" + std::to_string(constantID)), - /*stickified=*/zhighStickifiedConstOp.getStickifiedAttr(), - /*value=*/zhighStickifiedConstOp.getValueAttr(), - /*layout=*/layout, - /*offset=*/rewriter.getI64IntegerAttr(0), - /*alignment=*/zhighStickifiedConstOp.getAlignmentAttr()); - // #endif // NNPA_ZHIGH_STICKIFIEDCONST_GEN + /*value=*/valueAttr, + /*offset=*/nullptr, + /*alignment=*/stickifiedConstOp.getAlignmentAttr()); + // Increment constant ID: constantID++; - rewriter.replaceOp(op, constantOp.getResult()); + rewriter.replaceOp(op, constantGlobal.getResult()); return success(); } }; diff --git a/src/Accelerators/NNPA/Dialect/ZHigh/CMakeLists.txt b/src/Accelerators/NNPA/Dialect/ZHigh/CMakeLists.txt index af5bab1779..915ed61717 100644 --- a/src/Accelerators/NNPA/Dialect/ZHigh/CMakeLists.txt +++ b/src/Accelerators/NNPA/Dialect/ZHigh/CMakeLists.txt @@ -47,7 +47,6 @@ add_onnx_mlir_library(OMZHighOps OMONNXOps # Use ONNXShapeHelper OMLayoutHelper OMShapeHelperOpInterface - OMStickify OMNNPACompilerOptions MLIRIR diff --git a/src/Accelerators/NNPA/Dialect/ZHigh/ZHigh.td b/src/Accelerators/NNPA/Dialect/ZHigh/ZHigh.td index 8b17786bcd..d2624138c0 100644 --- a/src/Accelerators/NNPA/Dialect/ZHigh/ZHigh.td +++ b/src/Accelerators/NNPA/Dialect/ZHigh/ZHigh.td @@ -862,14 +862,11 @@ def ZHighStickifiedConstantOp:ZHigh_Op<"StickifiedConstant", [Pure]> { let summary = "ZHigh Stickified Constant operation"; let description = [{ This operator produces a constant tensor to store stickified data. - `value` attribute has original constant or stickified constant. - `stickified` attribute indicates the `value` is already stickified or not. Stickified data is opaque and must be 4K-aligned. One who produces the stickified data must make sure its size in bytes consistent with the output tensor's size. }]; - let arguments = (ins BoolAttr:$stickified, - OptionalAttr:$value, + let arguments = (ins OptionalAttr:$value, DefaultValuedAttr:$alignment); let results = (outs AnyZTensor:$output); } diff --git a/src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps/OpHelper.cpp b/src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps/OpHelper.cpp index 028b5ac528..f5b9ff910f 100644 --- a/src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps/OpHelper.cpp +++ b/src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps/OpHelper.cpp @@ -12,6 +12,7 @@ #include "src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps/OpHelper.hpp" #include "src/Accelerators/NNPA/Compiler/NNPACompilerOptions.hpp" +#include "src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps.hpp" #include "src/Accelerators/NNPA/Support/LayoutHelper.hpp" #include "src/Dialect/ONNX/DialectBuilder.hpp" @@ -481,55 +482,5 @@ IntegerAttr getDefaultSaturation(PatternRewriter &rewriter) { return IntegerAttr(); } -/// MLIR type to zDNN type. -zdnn_data_types mlirTypeToZDNNType(Type elementType) { - if (mlir::isa(elementType)) { - FloatType floatTy = mlir::cast(elementType); - if (floatTy.getWidth() == 16) { - return FP16; - } else if (floatTy.getWidth() == 32) { - return FP32; - } else - llvm_unreachable("Unsupported data type."); - } else - llvm_unreachable("Unsupported data type."); -} - -/// Get stickified data from denseElementAttribute -ArrayRef getStickifiedDataOfDenseElemAttr( - DenseElementsAttr denseAttr, StringAttr layout) { - ArrayRef shape = denseAttr.getType().getShape(); - Type elementType = denseAttr.getType().getElementType(); - int rank = shape.size(); - // Read attributes's raw data. - std::vector attrData; - getRawData(denseAttr, attrData); - // Call stickify. - zdnn_tensor_desc pre_tfrmd_desc, tfrmd_desc; - // pre-transformed desc. - zdnn_data_layouts zDNNLayout = - convertLayoutAttrToZDNNDataLayout(rank, layout); - // If zDNNLayout is NHWC, we stickify directly from NCHW. - if (zDNNLayout == ZDNN_NHWC) - zDNNLayout = ZDNN_NCHW; - zdnn_data_types zDNNType = onnx_mlir::zhigh::mlirTypeToZDNNType(elementType); - set_info_pre_transformed_desc(&pre_tfrmd_desc, zDNNLayout, zDNNType, shape); - // transformed desc. - zdnn_status status = generate_transformed_desc(&pre_tfrmd_desc, &tfrmd_desc); - assert(status == ZDNN_OK); - // Stick data using the software stickify. - zdnn_ztensor ztensor; - init_ztensor(&pre_tfrmd_desc, &tfrmd_desc, &ztensor); - status = allochelper_ztensor_alloc(&ztensor); - assert(status == ZDNN_OK); - status = stickify(&ztensor, attrData.data()); - assert(status == ZDNN_OK); - int64_t sizeInBytes = ztensor.buffer_size; - char *rawData = (char *)malloc(sizeInBytes); - memcpy(rawData, ztensor.buffer, sizeInBytes); - allochelper_ztensor_free(&ztensor); - return llvm::ArrayRef(rawData, sizeInBytes); -} - } // namespace zhigh } // namespace onnx_mlir diff --git a/src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps/OpHelper.hpp b/src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps/OpHelper.hpp index 4d353950a6..def0813d7b 100644 --- a/src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps/OpHelper.hpp +++ b/src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps/OpHelper.hpp @@ -16,7 +16,6 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinAttributes.h" #include "src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps.hpp" -#include "src/Accelerators/NNPA/Support/Stickify/Stickify.hpp" namespace onnx_mlir { namespace zhigh { @@ -89,13 +88,6 @@ bool hasNNPAUse(mlir::Value v); /// Get saturation settings. mlir::IntegerAttr getDefaultSaturation(mlir::PatternRewriter &rewriter); -/// MLIR type to zDNN type. -zdnn_data_types mlirTypeToZDNNType(mlir::Type elementType); - -/// Get stickified data from denseElementAttribute -mlir::ArrayRef getStickifiedDataOfDenseElemAttr( - mlir::DenseElementsAttr denseAttr, mlir::StringAttr layout); - } // namespace zhigh } // namespace onnx_mlir #endif diff --git a/src/Accelerators/NNPA/Dialect/ZLow/CMakeLists.txt b/src/Accelerators/NNPA/Dialect/ZLow/CMakeLists.txt index 99dd227c39..c259f721c3 100644 --- a/src/Accelerators/NNPA/Dialect/ZLow/CMakeLists.txt +++ b/src/Accelerators/NNPA/Dialect/ZLow/CMakeLists.txt @@ -11,13 +11,8 @@ add_onnx_mlir_library(OMZLowOps DEPENDS OMZLowIncGen OMONNXZLowCombineIncGen - OMKrnlGlobalOpInterface LINK_LIBS PUBLIC MLIRIR OMMlirDialects - OMZHighOps - - ACCEL_INCLUDE_DIRS PRIVATE - ${NNPA_INCLUDE_PATH} ) diff --git a/src/Accelerators/NNPA/Dialect/ZLow/ZLow.td b/src/Accelerators/NNPA/Dialect/ZLow/ZLow.td index 4376a3d90b..63fcb0704d 100644 --- a/src/Accelerators/NNPA/Dialect/ZLow/ZLow.td +++ b/src/Accelerators/NNPA/Dialect/ZLow/ZLow.td @@ -44,7 +44,6 @@ def ZMemRef : MemRefOf<[DLF16]>; //===----------------------------------------------------------------------===// include "mlir/Interfaces/SideEffectInterfaces.td" -include "src/Interface/KrnlGlobalOpInterface.td" def ZLowAddOp:ZLow_Op<"add", [MemRefsNormalizable, DeclareOpInterfaceMethods]> { @@ -548,20 +547,4 @@ def ZLowConvertF32ToDLF16VectorOp:ZLow_Op<"vec_f32_to_dlf16", [Pure]> { ]; } -def ZLowStickifiedConstantOp:ZLow_Op<"stickifiedConstant", [MemRefsNormalizable, - DeclareOpInterfaceMethods]> { - let summary = "ZLow Stickified Constant operation."; - let description = [{ - - }]; - let arguments = (ins AnyAttr:$shape, - StrAttr:$name, - BoolAttr:$stickified, - OptionalAttr:$value, - OptionalAttr:$layout, - OptionalAttr:$offset, - DefaultValuedAttr:$alignment); - let results = (outs ZMemRef:$output); -} - #endif // ZLOW_OPS diff --git a/src/Accelerators/NNPA/Dialect/ZLow/ZLowOps.cpp b/src/Accelerators/NNPA/Dialect/ZLow/ZLowOps.cpp index 4cf9d79b2b..7526933777 100644 --- a/src/Accelerators/NNPA/Dialect/ZLow/ZLowOps.cpp +++ b/src/Accelerators/NNPA/Dialect/ZLow/ZLowOps.cpp @@ -12,27 +12,19 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/Affine/Analysis/Utils.h" #include "mlir/Dialect/Shape/IR/Shape.h" #include "mlir/Dialect/Traits.h" #include "mlir/IR/Block.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinOps.h" -#include "mlir/IR/DialectResourceBlobManager.h" #include "mlir/IR/IntegerSet.h" #include "mlir/IR/Matchers.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/PatternMatch.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallBitVector.h" -#include "llvm/ADT/TypeSwitch.h" -#include "llvm/Support/Debug.h" -#include "src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps/OpHelper.hpp" #include "src/Accelerators/NNPA/Dialect/ZLow/ZLowOps.hpp" -#include "src/Accelerators/NNPA/Support/LayoutHelper.hpp" -#include "src/Accelerators/NNPA/Support/Stickify/Stickify.hpp" -#include "src/Dialect/ONNX/ONNXOps/OpHelper.hpp" using namespace mlir; @@ -366,75 +358,6 @@ void ZLowBatchNormOp::getEffects( SideEffects::DefaultResource::get()); } -/// Create a buffer for constant. Stickified data is -/// created and set if `stickified` attribute is false. -ArrayRef ZLowStickifiedConstantOp::getBuffer() { - MLIRContext *context = getOperation()->getContext(); - PatternRewriter rewriter(context); - ArrayRef ret; - if (getValueAttr()) { - StringAttr layout = getLayoutAttr(); - auto dataAttr = getValue().value(); - if (!getStickified()) { - // The case which the data in value attribute is still not stickified. - // Get the buffer after stickification. - DenseElementsAttr denseAttr = mlir::cast(dataAttr); - ret = - onnx_mlir::zhigh::getStickifiedDataOfDenseElemAttr(denseAttr, layout); - } else { - // Get the buffer from `value` attribute. - int64_t sizeInBytes = getBufferSize(); - char *rawData = (char *)malloc(sizeInBytes); - std::vector attrData; - getRawData(dataAttr, attrData); - memcpy(rawData, attrData.data(), sizeInBytes); - ret = llvm::ArrayRef(rawData, sizeInBytes); - } - } - return ret; -} - -/// Get buffer size from result. -uint64_t ZLowStickifiedConstantOp::getBufferSize() { - const Type type = getOperation()->getResults()[0].getType(); - const MemRefType memRefTy = mlir::cast(type); - auto sizeInBytes = affine::getIntOrFloatMemRefSizeInBytes(memRefTy); - return sizeInBytes.has_value() ? sizeInBytes.value() : 0; -} - -/// Free buffer created by getBuffer(). -void ZLowStickifiedConstantOp::freeBuffer(ArrayRef rawData) { - free(const_cast(rawData.data())); - return; -} - -/// Get a buffer, set/copy it to value attribute, and free the buffer. -void ZLowStickifiedConstantOp::updateValueAttr() { - MLIRContext *context = getOperation()->getContext(); - PatternRewriter rewriter(context); - // Set buffer when the value attribute is still not stickified or is splat - // with dense element attribute. - if (getValueAttr()) { - bool isStickified = getStickified(); - bool isSplat = false; - if (auto denseAttr = mlir::dyn_cast(getValue().value())) - isSplat = denseAttr.isSplat(); - if (!isStickified || isSplat) { - ArrayRef rawData = getBuffer(); - int64_t sizeInBytes = getBufferSize(); - DenseResourceElementsAttr valueAttr = DenseUI8ResourceElementsAttr::get( - RankedTensorType::get({sizeInBytes}, rewriter.getI8Type()), - getOperation() - ->getDialect() - ->getNamespace(), // use the dialect as the blob "hint" - HeapAsmResourceBlob::allocateAndCopyWithAlign( - rawData, alignof(char))); - setValueAttr(valueAttr); - freeBuffer(rawData); - } - } -} - } // namespace zlow } // namespace onnx_mlir diff --git a/src/Accelerators/NNPA/Dialect/ZLow/ZLowOps.hpp b/src/Accelerators/NNPA/Dialect/ZLow/ZLowOps.hpp index 9ebeb64447..2050779dcb 100644 --- a/src/Accelerators/NNPA/Dialect/ZLow/ZLowOps.hpp +++ b/src/Accelerators/NNPA/Dialect/ZLow/ZLowOps.hpp @@ -24,8 +24,6 @@ #include "mlir/IR/Dialect.h" #include "mlir/IR/OpDefinition.h" -#include "src/Interface/KrnlGlobalOpInterface.hpp" - /// Include the auto-generated header files containing the declarations of the /// ZLow dialect and operations. #include "src/Accelerators/NNPA/Dialect/ZLow/ZLowDialect.hpp.inc" diff --git a/src/Accelerators/NNPA/Pass/NNPAPasses.hpp b/src/Accelerators/NNPA/Pass/NNPAPasses.hpp index b15e7f165d..e1abed7ba2 100644 --- a/src/Accelerators/NNPA/Pass/NNPAPasses.hpp +++ b/src/Accelerators/NNPA/Pass/NNPAPasses.hpp @@ -49,6 +49,10 @@ std::unique_ptr createZHighLayoutPropagationPass(); /// Pass for constant propagation at ZHighIR. std::unique_ptr createZHighConstPropagationPass(); +/// Pass for scrubbing constants at ZHighIR. +std::unique_ptr createZHighScrubDisposablePass( + bool closeAfter = true); + /// Pass for clipping values to dlfloat before stickification at ZHighIR. std::unique_ptr createZHighClipToDLFloatPass(); diff --git a/src/Accelerators/NNPA/Transform/ZHigh/CMakeLists.txt b/src/Accelerators/NNPA/Transform/ZHigh/CMakeLists.txt index dfc7e7f5b0..30378c0f9e 100644 --- a/src/Accelerators/NNPA/Transform/ZHigh/CMakeLists.txt +++ b/src/Accelerators/NNPA/Transform/ZHigh/CMakeLists.txt @@ -12,6 +12,7 @@ add_onnx_mlir_library(OMZHighConstPropagation MLIRRewrite MLIRTransformUtils OMLayoutHelper + OMStickify OMZHighOps OMONNXOps @@ -46,9 +47,6 @@ add_onnx_mlir_library(OMZHighClipToDLFloat MLIRTransformUtils OMZHighOps OMONNXOps - - ACCEL_INCLUDE_DIRS PRIVATE - ${NNPA_INCLUDE_PATH} ) add_onnx_mlir_rewriter(ZHighDecomposeStickUnstick) @@ -86,3 +84,16 @@ add_onnx_mlir_library(OMZHighRecomposeToStickUnstick ACCEL_INCLUDE_DIRS PRIVATE ${NNPA_INCLUDE_PATH} ) + +add_onnx_mlir_library(OMZHighScrubDisposable + ZHighScrubDisposablePass.cpp + + LINK_LIBS PUBLIC + MLIRRewrite + MLIRTransformUtils + OMZHighOps + OMONNXOps + + ACCEL_INCLUDE_DIRS PRIVATE + ${NNPA_INCLUDE_PATH} + ) diff --git a/src/Accelerators/NNPA/Transform/ZHigh/ZHighConstPropagation.cpp b/src/Accelerators/NNPA/Transform/ZHigh/ZHighConstPropagation.cpp index 62724c1c73..6478052c37 100644 --- a/src/Accelerators/NNPA/Transform/ZHigh/ZHighConstPropagation.cpp +++ b/src/Accelerators/NNPA/Transform/ZHigh/ZHighConstPropagation.cpp @@ -21,13 +21,12 @@ #include "mlir/Transforms/GreedyPatternRewriteDriver.h" #include "src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps.hpp" -#include "src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps/OpHelper.hpp" #include "src/Accelerators/NNPA/Pass/NNPAPasses.hpp" #include "src/Accelerators/NNPA/Support/LayoutHelper.hpp" #include "src/Accelerators/NNPA/Support/Stickify/Stickify.hpp" -#include "src/Compiler/CompilerOptions.hpp" #include "src/Dialect/ONNX/ONNXOps.hpp" #include "src/Dialect/ONNX/ONNXOps/OpHelper.hpp" +#include "src/Dialect/ONNX/OnnxElementsAttrBuilder.hpp" using namespace mlir; using namespace onnx_mlir; @@ -36,6 +35,53 @@ using namespace onnx_mlir::zhigh; namespace onnx_mlir { namespace zhigh { +/// Get raw data from a dense attribute. +static void getRawData(ElementsAttr attr_, std::vector &data) { + ShapedType tensorType = mlir::cast(attr_.getType()); + Type elemTy = tensorType.getElementType(); + int64_t numElements = tensorType.getNumElements(); + + // Use DenseElementsAttr for boolean values. DisposableElementsAttr handles + // bool differently. + ElementsAttr attr = attr_; + if (elemTy.isInteger(1)) + attr = ElementsAttrBuilder::toDenseElementsAttr(attr_); + + auto denseAttr = mlir::dyn_cast_or_null(attr); + auto disposalAttr = mlir::dyn_cast_or_null(attr); + assert((denseAttr || disposalAttr) && + "Must be DenseElementsAttr or DisposableElementsAttr"); + + if (disposalAttr) { + ArrayBuffer dstBytes = disposalAttr.getRawBytes(); + data = dstBytes.get(); + return; + } + + ArrayRef rawData = denseAttr.getRawData(); + if (denseAttr.isSplat()) { + // Broadcast the splat value. + for (int i = 0; i < numElements; i++) + data.insert(data.end(), rawData.begin(), rawData.end()); + } else { + data = rawData; + } +} + +/// MLIR type to zDNN type. +zdnn_data_types mlirTypeToZDNNType(Type elementType) { + if (mlir::isa(elementType)) { + FloatType floatTy = mlir::cast(elementType); + if (floatTy.getWidth() == 16) { + return FP16; + } else if (floatTy.getWidth() == 32) { + return FP32; + } else + llvm_unreachable("Unsupported data type."); + } else + llvm_unreachable("Unsupported data type."); +} + /// Emit a ZHighStikifiedConstant using information from a stickified ztensor. ZHighStickifiedConstantOp emitZHighStickifiedConstant(PatternRewriter &rewriter, Location loc, zdnn_ztensor *ztensor, Type outputType) { @@ -43,22 +89,42 @@ ZHighStickifiedConstantOp emitZHighStickifiedConstant(PatternRewriter &rewriter, // Create a ZHighStickifiedConstantOp. ZHighStickifiedConstantOp stickifiedConstant = rewriter.create(loc, outputType, - /*stickified=*/rewriter.getBoolAttr(true), /*value=*/nullptr, /*alignment=*/rewriter.getI64IntegerAttr(4096)); - // Use an dense resource attribute to store stickified data. // Attribute type: tensor int64_t sizeInBytes = ztensor->buffer_size; - DenseResourceElementsAttr valueAttr = DenseUI8ResourceElementsAttr::get( - RankedTensorType::get({sizeInBytes}, rewriter.getI8Type()), - stickifiedConstant.getOperation() - ->getDialect() - ->getNamespace(), // use the dialect as the blob "hint" - HeapAsmResourceBlob::allocateAndCopyWithAlign( - llvm::ArrayRef((char *)ztensor->buffer, sizeInBytes), alignof(char))); - stickifiedConstant.setValueAttr(valueAttr); + // Currently, using DenseResourceElementsAttr leads to less memory consumption + // at compile time. + // In the future, if there is a need to do constant prop for ZHigh Ops whose + // inputs are stickified data, then using ElementsAttr is potentially better. + // In this case, to print or parse ElementsAttr in lit tests, + // ZHighStickifiedConstantOp would be updated to support custom printer and + // parser. + bool useDenseResourceElementsAttr = true; + if (useDenseResourceElementsAttr) { + DenseResourceElementsAttr valueAttr = DenseUI8ResourceElementsAttr::get( + RankedTensorType::get({sizeInBytes}, rewriter.getI8Type()), + stickifiedConstant.getOperation() + ->getDialect() + ->getNamespace(), // use the dialect as the blob "hint" + HeapAsmResourceBlob::allocateAndCopyWithAlign( + llvm::ArrayRef((char *)ztensor->buffer, sizeInBytes), + alignof(char))); + allochelper_ztensor_free(ztensor); + stickifiedConstant.setValueAttr(valueAttr); + } else { + RankedTensorType dataType = + RankedTensorType::get({sizeInBytes}, rewriter.getI8Type()); + std::unique_ptr memBuf = + llvm::MemoryBuffer::getMemBuffer( + StringRef((char *)ztensor->buffer, sizeInBytes), "", + /*RequiresNullTerminator*/ false); + ElementsAttr valueAttr = OnnxElementsAttrBuilder(rewriter.getContext()) + .fromMemoryBuffer(dataType, std::move(memBuf)); + stickifiedConstant.setValueAttr(valueAttr); + } return stickifiedConstant; } @@ -66,45 +132,43 @@ ZHighStickifiedConstantOp emitZHighStickifiedConstant(PatternRewriter &rewriter, ZHighStickifiedConstantOp createConstantForStick(PatternRewriter &rewriter, Value replacingValue, Value input, StringAttr layout) { Location loc = replacingValue.getLoc(); - Operation *op = input.getDefiningOp(); + ArrayRef shape = mlir::cast(input.getType()).getShape(); + Type elementType = mlir::cast(input.getType()).getElementType(); + int rank = shape.size(); + // Read dense attributes. - DenseElementsAttr dataAttr = mlir::dyn_cast_or_null( - op->getAttrOfType<::mlir::Attribute>("value")); + ElementsAttr dataAttr = getElementAttributeFromONNXValue(input); assert(dataAttr && "Attribute is null"); - // Keep previous implementation about generating stickified data at - // ZHighConstPropagationPass. To use this, comment in and set directive " - // NNPA_ZHIGH_STICKIFIEDCONST_GEN" - // - // #ifdef NNPA_ZHIGH_STICKIFIEDCONST_GEN - // // Set stickified data. - // ArrayRef stickifiedData = - // getStickifiedDataOfDenseElemAttr(dataAttr, layout); - // // Create a ZHighStickifiedConstantOp. - // ZHighStickifiedConstantOp constantOp = - // rewriter.create(loc, - // replacingValue.getType(), - // /*stickified=*/rewriter.getBoolAttr(true), - // /*value=*/nullptr, - // /*alignment=*/rewriter.getI64IntegerAttr(4096)); - // - // // Use an dense resource attribute to store stickified data. - // // Attribute type: tensor - // DenseResourceElementsAttr valueAttr = DenseUI8ResourceElementsAttr::get( - // RankedTensorType::get({stickifiedData.size()}, rewriter.getI8Type()), - // constantOp.getOperation() - // ->getDialect() - // ->getNamespace(), // use the dialect as the blob "hint" - // HeapAsmResourceBlob::allocateAndCopyWithAlign( - // stickifiedData, alignof(char))); - // - // constantOp.setValueAttr(valueAttr); - // #else - ZHighStickifiedConstantOp constantOp = - rewriter.create(loc, replacingValue.getType(), - /*stickified=*/rewriter.getBoolAttr(false), - /*value=*/dataAttr, - /*alignment=*/rewriter.getI64IntegerAttr(4096)); - // #endif // NNPA_ZHIGH_STICKIFIEDCONST_GEN + // Read attributes's raw data. + std::vector rawData; + getRawData(dataAttr, rawData); + // assert((rawData.size() == (uint64_t)getMemRefSizeInBytes(input)) && + // "Data size mismatched"); + + // Call stickify. + zdnn_tensor_desc pre_tfrmd_desc, tfrmd_desc; + // pre-transformed desc. + zdnn_data_layouts zDNNLayout = + convertLayoutAttrToZDNNDataLayout(rank, layout); + // If zDNNLayout is NHWC, we stickify directly from NCHW. + if (zDNNLayout == ZDNN_NHWC) + zDNNLayout = ZDNN_NCHW; + zdnn_data_types zDNNType = mlirTypeToZDNNType(elementType); + set_info_pre_transformed_desc(&pre_tfrmd_desc, zDNNLayout, zDNNType, shape); + // transformed desc. + zdnn_status status = generate_transformed_desc(&pre_tfrmd_desc, &tfrmd_desc); + assert(status == ZDNN_OK); + // Stick data using the software stickify. + zdnn_ztensor ztensor; + init_ztensor(&pre_tfrmd_desc, &tfrmd_desc, &ztensor); + status = allochelper_ztensor_alloc(&ztensor); + assert(status == ZDNN_OK); + status = stickify(&ztensor, rawData.data()); + assert(status == ZDNN_OK); + // Emit a constant global in ZHigh dialect. + ZHighStickifiedConstantOp constantOp = emitZHighStickifiedConstant( + rewriter, loc, &ztensor, replacingValue.getType()); + return constantOp; } @@ -112,10 +176,6 @@ ZHighStickifiedConstantOp createConstantForStickForLSTM( PatternRewriter &rewriter, Value replacingValue, Value inputF, Value inputI, Value inputC, Value inputO) { Location loc = replacingValue.getLoc(); - Operation *fOp = inputF.getDefiningOp(); - Operation *iOp = inputI.getDefiningOp(); - Operation *cOp = inputC.getDefiningOp(); - Operation *oOp = inputO.getDefiningOp(); ArrayRef fShape = mlir::cast(inputF.getType()).getShape(); @@ -123,14 +183,10 @@ ZHighStickifiedConstantOp createConstantForStickForLSTM( Type elementType = mlir::cast(inputF.getType()).getElementType(); // Read dense attributes. - DenseElementsAttr fDataAttr = mlir::dyn_cast_or_null( - fOp->getAttrOfType<::mlir::Attribute>("value")); - DenseElementsAttr iDataAttr = mlir::dyn_cast_or_null( - iOp->getAttrOfType<::mlir::Attribute>("value")); - DenseElementsAttr cDataAttr = mlir::dyn_cast_or_null( - cOp->getAttrOfType<::mlir::Attribute>("value")); - DenseElementsAttr oDataAttr = mlir::dyn_cast_or_null( - oOp->getAttrOfType<::mlir::Attribute>("value")); + ElementsAttr fDataAttr = getElementAttributeFromONNXValue(inputF); + ElementsAttr iDataAttr = getElementAttributeFromONNXValue(inputI); + ElementsAttr cDataAttr = getElementAttributeFromONNXValue(inputC); + ElementsAttr oDataAttr = getElementAttributeFromONNXValue(inputO); assert((fDataAttr && iDataAttr && cDataAttr && oDataAttr) && "Attribute is null"); // Read attributes's raw data. @@ -174,9 +230,6 @@ ZHighStickifiedConstantOp createConstantForStickForGRU( PatternRewriter &rewriter, Value replacingValue, Value inputZ, Value inputR, Value inputH) { Location loc = replacingValue.getLoc(); - Operation *zOp = inputZ.getDefiningOp(); - Operation *rOp = inputR.getDefiningOp(); - Operation *hOp = inputH.getDefiningOp(); ArrayRef zShape = mlir::cast(inputZ.getType()).getShape(); @@ -184,12 +237,9 @@ ZHighStickifiedConstantOp createConstantForStickForGRU( Type elementType = mlir::cast(inputZ.getType()).getElementType(); // Read dense attributes. - DenseElementsAttr zDataAttr = mlir::dyn_cast_or_null( - zOp->getAttrOfType<::mlir::Attribute>("value")); - DenseElementsAttr rDataAttr = mlir::dyn_cast_or_null( - rOp->getAttrOfType<::mlir::Attribute>("value")); - DenseElementsAttr hDataAttr = mlir::dyn_cast_or_null( - hOp->getAttrOfType<::mlir::Attribute>("value")); + ElementsAttr zDataAttr = getElementAttributeFromONNXValue(inputZ); + ElementsAttr rDataAttr = getElementAttributeFromONNXValue(inputR); + ElementsAttr hDataAttr = getElementAttributeFromONNXValue(inputH); assert((zDataAttr && rDataAttr && hDataAttr) && "Attribute is null"); // Read attributes's raw data. std::vector rawZData, rawHData, rawRData, rawOData; @@ -237,10 +287,111 @@ namespace { /// Include the patterns defined in the Declarative Rewrite framework. #include "src/Accelerators/NNPA/Transform/ZHigh/ONNXZHighConstPropagation.inc" +static void replaceOpAndGC( + PatternRewriter &rewriter, Operation *op, ValueRange newValues) { + for (Value v : op->getOperands()) { + // v is consumed by only the current stick op. + if (!v.hasOneUse()) + continue; + if (auto cop = v.getDefiningOp()) { + if (auto disposableAttr = + mlir::dyn_cast(cop.getValueAttr())) { + // Since the current op is the only consummer of the constant, + // this constant op will be dead soon after the current op is replaced + // (but the attribute's buffer is not disposed automatically until the + // next call of garbage collector). So, it's safe to dispose the + // attribute's buffer now in order to eagerly save memory. + // + // Once the buffer is dispose, any touch to the attribute would be + // invalid. So we just remove it from the constant operation. + disposableAttr.dispose(); + cop.removeValueAttr(); + } + } + } + rewriter.replaceOp(op, newValues); +} + +// zhigh.Stick (c) = krnl.global(c1), where c1 is stickified data. +// Always saturate constants. +struct ConstantStickPattern : public OpRewritePattern { + ConstantStickPattern(MLIRContext *context) : OpRewritePattern(context) {} + LogicalResult matchAndRewrite( + ZHighStickOp stickOp, PatternRewriter &rewriter) const override { + Value input = stickOp.getIn(); + Value output = stickOp.getOut(); + StringAttr layout = stickOp.getLayoutAttr(); + + // Match + if (!isDenseONNXConstant(input)) { + return failure(); + } + + // Rewrite + Value stickifiedVal = + createConstantForStick(rewriter, output, input, layout); + replaceOpAndGC(rewriter, stickOp, stickifiedVal); + return success(); + } +}; + +// zhigh.StickForGRU (c1, c2, c3) = krnl.global(c) +// where c is stickified data. +struct ConstantStickForGRUPattern + : public OpRewritePattern { + ConstantStickForGRUPattern(MLIRContext *context) + : OpRewritePattern(context) {} + LogicalResult matchAndRewrite( + ZHighStickForGRUOp stickOp, PatternRewriter &rewriter) const override { + Value zGate = stickOp.getZGate(); + Value rGate = stickOp.getRGate(); + Value hGate = stickOp.getHGate(); + Value output = stickOp.getOut(); + + // Match + if (!isDenseONNXConstant(zGate) || !isDenseONNXConstant(rGate) || + !isDenseONNXConstant(hGate)) { + return failure(); + } + + // Rewrite + Value stickifiedVal = + createConstantForStickForGRU(rewriter, output, zGate, rGate, hGate); + replaceOpAndGC(rewriter, stickOp, stickifiedVal); + return success(); + } +}; + +// zhigh.StickForLSTM (c1, c2, c3, c4) = krnl.global(c) +// where c is stickified data. +struct ConstantStickForLSTMPattern + : public OpRewritePattern { + ConstantStickForLSTMPattern(MLIRContext *context) + : OpRewritePattern(context) {} + LogicalResult matchAndRewrite( + ZHighStickForLSTMOp stickOp, PatternRewriter &rewriter) const override { + Value fGate = stickOp.getFGate(); + Value iGate = stickOp.getIGate(); + Value cGate = stickOp.getCGate(); + Value oGate = stickOp.getOGate(); + Value output = stickOp.getOut(); + + // Match + if (!isDenseONNXConstant(fGate) || !isDenseONNXConstant(iGate) || + !isDenseONNXConstant(cGate) || !isDenseONNXConstant(oGate)) { + return failure(); + } + + // Rewrite + Value stickifiedVal = createConstantForStickForLSTM( + rewriter, output, fGate, iGate, cGate, oGate); + replaceOpAndGC(rewriter, stickOp, stickifiedVal); + return success(); + } +}; + struct ZHighConstPropagationPass - //: public PassWrapper> { - : public PassWrapper> { + : public PassWrapper> { MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ZHighConstPropagationPass) @@ -251,11 +402,13 @@ struct ZHighConstPropagationPass } void runOnOperation() override { - auto function = getOperation(); + ModuleOp moduleOp = getOperation(); ConversionTarget target(getContext()); RewritePatternSet patterns(&getContext()); - populateWithGenerated(patterns); - (void)applyPatternsAndFoldGreedily(function, std::move(patterns)); + patterns.insert(patterns.getContext()); + patterns.insert(patterns.getContext()); + patterns.insert(patterns.getContext()); + (void)applyPatternsAndFoldGreedily(moduleOp, std::move(patterns)); } }; } // anonymous namespace diff --git a/src/Accelerators/NNPA/Transform/ZHigh/ZHighConstPropagation.td b/src/Accelerators/NNPA/Transform/ZHigh/ZHighConstPropagation.td index 699d425780..2646d6dba3 100644 --- a/src/Accelerators/NNPA/Transform/ZHigh/ZHighConstPropagation.td +++ b/src/Accelerators/NNPA/Transform/ZHigh/ZHighConstPropagation.td @@ -52,39 +52,4 @@ def CreateConstantForStickForGRU : NativeCodeCall< "createConstantForStickForGRU($_builder, $0, $1, $2, $3)" >; -// zhigh.Stick (c) = krnl.global(c1), where c1 is stickified data. -// Always saturate constants. -def ConstantStickPattern : Pat< - (ZHighStickOp:$stickOp - (ONNXConstantOp:$c $_, $_, $_, $_, $_, $_, $_, $_), - $layout, $_), - (CreateConstantForStick $stickOp, $c, $layout), - [(IsFromDenseONNXConstantOp:$c)] ->; - -// zhigh.StickForLSTM (c1, c2, c3, c4) = krnl.global(c) -// where c is stickified data. -def ConstantStickForLSTMPattern : Pat< - (ZHighStickForLSTMOp:$stickOp - (ONNXConstantOp:$c1 $_, $_, $_, $_, $_, $_, $_, $_), - (ONNXConstantOp:$c2 $_, $_, $_, $_, $_, $_, $_, $_), - (ONNXConstantOp:$c3 $_, $_, $_, $_, $_, $_, $_, $_), - (ONNXConstantOp:$c4 $_, $_, $_, $_, $_, $_, $_, $_)), - (CreateConstantForStickForLSTM $stickOp, $c1, $c2, $c3, $c4), - [(IsFromDenseONNXConstantOp:$c1), (IsFromDenseONNXConstantOp:$c2), - (IsFromDenseONNXConstantOp:$c3), (IsFromDenseONNXConstantOp:$c4)] ->; - -// zhigh.StickForGRU (c1, c2, c3) = krnl.global(c) -// where c is stickified data. -def ConstantStickForGRUPattern : Pat< - (ZHighStickForGRUOp:$stickOp - (ONNXConstantOp:$c1 $_, $_, $_, $_, $_, $_, $_, $_), - (ONNXConstantOp:$c2 $_, $_, $_, $_, $_, $_, $_, $_), - (ONNXConstantOp:$c3 $_, $_, $_, $_, $_, $_, $_, $_)), - (CreateConstantForStickForGRU $stickOp, $c1, $c2, $c3), - [(IsFromDenseONNXConstantOp:$c1), (IsFromDenseONNXConstantOp:$c2), - (IsFromDenseONNXConstantOp:$c3)] ->; - #endif // ZHIGH_CONST_PROPAGATION diff --git a/src/Accelerators/NNPA/Transform/ZHigh/ZHighScrubDisposablePass.cpp b/src/Accelerators/NNPA/Transform/ZHigh/ZHighScrubDisposablePass.cpp new file mode 100644 index 0000000000..435c75fd1f --- /dev/null +++ b/src/Accelerators/NNPA/Transform/ZHigh/ZHighScrubDisposablePass.cpp @@ -0,0 +1,64 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + */ + +//===-------------------- ZHighScrubDisposablePass.cpp --------------------===// +// +// Replaces each DisposableElementsAttr with a DenseElementsAttr. +// +//===----------------------------------------------------------------------===// + +#include "mlir/IR/BuiltinOps.h" +#include "mlir/Transforms/Passes.h" + +#include "src/Accelerators/NNPA/Dialect/ZHigh/ZHighOps.hpp" +#include "src/Dialect/ONNX/ElementsAttr/DisposablePool.hpp" +#include "src/Dialect/ONNX/ONNXDialect.hpp" +#include "src/Dialect/ONNX/ONNXOps.hpp" + +using namespace mlir; + +namespace onnx_mlir { + +namespace zhigh { +namespace { + +struct ZHighScrubDisposablePass + : public PassWrapper> { + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ZHighScrubDisposablePass) + + ZHighScrubDisposablePass(bool closeAfter) : closeAfter(closeAfter) {} + + StringRef getArgument() const override { return "zhigh-scrub-disposable"; } + + void runOnOperation() final { + ModuleOp moduleOp = getOperation(); + DisposablePool *pool = getDisposablePool(); + pool->scrub(moduleOp, + {{ONNXConstantOp::getOperationName(), "value"}, + {ONNXConstantOfShapeOp::getOperationName(), "value"}, + {ZHighStickifiedConstantOp::getOperationName(), "value"}}); + if (closeAfter) + pool->close(); + } + + DisposablePool *getDisposablePool() { + // It can be hard to get the MLIRContext at the time of construction + // of the pass, so we look it up the first time the pass is run. + if (!disposablePool) + disposablePool = DisposablePool::get(&getContext()); + return disposablePool; + } + + const bool closeAfter; + DisposablePool *disposablePool = nullptr; +}; + +} // namespace + +std::unique_ptr createZHighScrubDisposablePass(bool closeAfter) { + return std::make_unique(closeAfter); +} + +} // namespace zhigh +} // namespace onnx_mlir diff --git a/src/Accelerators/NNPA/Transform/ZLow/ZLowDummyOpForMultiDerefPass.cpp b/src/Accelerators/NNPA/Transform/ZLow/ZLowDummyOpForMultiDerefPass.cpp index c7e8ba9a65..b93a4f7688 100644 --- a/src/Accelerators/NNPA/Transform/ZLow/ZLowDummyOpForMultiDerefPass.cpp +++ b/src/Accelerators/NNPA/Transform/ZLow/ZLowDummyOpForMultiDerefPass.cpp @@ -58,7 +58,7 @@ class ZLowDummyOpForMultiDerefPass ZLowDialect::getDialectNamespace()) { ValueRange operands = op->getOperands(); llvm::SmallSet processed; - for (int64_t i = 0; i < (int64_t)operands.size() - 1; ++i) { + for (uint64_t i = 0; i < operands.size() - 1; ++i) { if (processed.contains(i)) continue; for (uint64_t j = i + 1; j < operands.size(); ++j) { diff --git a/src/Compiler/CompilerPasses.cpp b/src/Compiler/CompilerPasses.cpp index 10d8d784a9..0b5dd418ac 100644 --- a/src/Compiler/CompilerPasses.cpp +++ b/src/Compiler/CompilerPasses.cpp @@ -67,8 +67,9 @@ void addONNXToMLIRPasses(mlir::PassManager &pm, bool targetCPU, // In future, only the dynamic pass, ONNXOpTransformPass, will be used for // this function. - pm.addInstrumentation( - std::make_unique(pm.getContext())); + if (!donotScrubDisposableElementsAttr) + pm.addInstrumentation( + std::make_unique(pm.getContext())); // Decompose first. Eliminates some unsupported ops without shape inference. pm.addNestedPass(onnx_mlir::createDecomposeONNXToONNXPass()); diff --git a/src/Conversion/KrnlToLLVM/CMakeLists.txt b/src/Conversion/KrnlToLLVM/CMakeLists.txt index 7a42037e08..92948137be 100644 --- a/src/Conversion/KrnlToLLVM/CMakeLists.txt +++ b/src/Conversion/KrnlToLLVM/CMakeLists.txt @@ -2,10 +2,10 @@ add_onnx_mlir_library(OMKrnlToLLVM ConvertKrnlToLLVM.cpp - KrnlGlobalOpInterface.cpp KrnlFindIndex.cpp KrnlCall.cpp KrnlEntryPoint.cpp + KrnlGlobal.cpp KrnlInstrument.cpp KrnlMemcpy.cpp KrnlNone.cpp @@ -22,7 +22,6 @@ add_onnx_mlir_library(OMKrnlToLLVM LINK_LIBS PUBLIC OMAccelerator - OMKrnlGlobalOpInterface OMSupport MLIRAffineToStandard MLIRArithTransforms diff --git a/src/Conversion/KrnlToLLVM/ConvertKrnlToLLVM.cpp b/src/Conversion/KrnlToLLVM/ConvertKrnlToLLVM.cpp index 23555c4b46..d33abe5918 100644 --- a/src/Conversion/KrnlToLLVM/ConvertKrnlToLLVM.cpp +++ b/src/Conversion/KrnlToLLVM/ConvertKrnlToLLVM.cpp @@ -211,17 +211,6 @@ void populateAffineAndKrnlToLLVMConversion(RewritePatternSet &patterns, // Use polynomial approximation for math.{tanh, sin, cos and exp} for better // performance. populateMathPolynomialApproximationPatterns(patterns); - // `arith.maxnumf/arith.minnumf` can be replaced with - // `llvm.intr.maxnum/llvm.intr.minnum` by - // populateArithToLLVMConversionPatterns, or with `arith.cmpf` and - // `arith.select` by populateArithExpandOpsPatterns. Which is applied for - // depends on the order in which the pattterns are applied. Currently, it - // should be replaced with `llvm.intr.maxnum/llvm.intr.minnum` because - // `arith.cmpf` and `arith.select do not work in float16 on ppc64le and cannot - // use SIMD, but currently there is no way to specify the order. From testing, - // following two line generates expected replacement We need to consider to - // specify the order, but we use this workaround for now. - arith::populateArithToLLVMConversionPatterns(typeConverter, patterns); arith::populateArithExpandOpsPatterns(patterns); populateMathToLLVMConversionPatterns(typeConverter, patterns); populateFuncToLLVMConversionPatterns(typeConverter, patterns); @@ -230,6 +219,7 @@ void populateAffineAndKrnlToLLVMConversion(RewritePatternSet &patterns, if (enableParallel) { populateOpenMPToLLVMConversionPatterns(typeConverter, patterns); } + arith::populateArithToLLVMConversionPatterns(typeConverter, patterns); cf::populateControlFlowToLLVMConversionPatterns(typeConverter, patterns); krnl::populateKrnlToLLVMConversion(typeConverter, patterns, ctx, @@ -475,8 +465,8 @@ bool extractConstantsToFile(ModuleOp &module, std::string filepath, // Check constants with thresholds. // Do not count constants whose size is <= singleThreshold. uint64_t totalSize = 0; - SmallVector globalOfInterest; - module.walk([&](KrnlGlobalOpInterface op) { + SmallVector globalOfInterest; + module.walk([&](KrnlGlobalOp op) { // Ignore constants that are return values. bool isReturnedValue = false; for (Operation *user : op.getResult().getUsers()) { @@ -492,23 +482,22 @@ bool extractConstantsToFile(ModuleOp &module, std::string filepath, // For an unknown reason, enabling constants of bool caused segfault in the // IBM granite.20B model (The model with KV cache) at 1265 input tokens. // See issue https://github.com/onnx/onnx-mlir/issues/2713. - if (llvm::cast(op.getResult().getType()) + if (llvm::cast(op->getResult(0).getType()) .getElementType() .isInteger(1)) return WalkResult::advance(); // Get raw data from DenseElementsAttr or DenseResourceElementsAttr. - uint64_t bufferSize = op.getBufferSize(); - if (bufferSize <= singleThreshold) + ArrayRef rawData = getRawData(op); + if (rawData.empty()) + return WalkResult::advance(); + + auto valueAttr = mlir::cast(op.getValue().value()); + if (valueAttr.isSplat() || rawData.size() <= singleThreshold) return WalkResult::advance(); - if (op.getValueAttr()) { - auto valueAttr = mlir::cast(op.getValue().value()); - if (valueAttr.isSplat()) - return WalkResult::advance(); - } globalOfInterest.emplace_back(op); - totalSize += bufferSize; + totalSize += rawData.size(); return WalkResult::advance(); }); // Do not use file if the total size of satisfied constants is <= @@ -518,16 +507,15 @@ bool extractConstantsToFile(ModuleOp &module, std::string filepath, // Sort constants in the non-descending order of alignment values. // Non-alignment is the smallest value (-1), the others are positive. - llvm::sort(globalOfInterest, - [&](KrnlGlobalOpInterface left, KrnlGlobalOpInterface right) { - int64_t leftAlign = -1; - int64_t rightAlign = -1; - if (left.getAlignment().has_value()) - leftAlign = left.getAlignment().value(); - if (right.getAlignment().has_value()) - rightAlign = right.getAlignment().value(); - return (leftAlign < rightAlign); - }); + llvm::sort(globalOfInterest, [&](KrnlGlobalOp left, KrnlGlobalOp right) { + int64_t leftAlign = -1; + int64_t rightAlign = -1; + if (left.getAlignment().has_value()) + leftAlign = left.getAlignment().value(); + if (right.getAlignment().has_value()) + rightAlign = right.getAlignment().value(); + return (leftAlign < rightAlign); + }); // Store each constant into single file. // Constants with the highest alignment will be packed first in the file. @@ -537,8 +525,8 @@ bool extractConstantsToFile(ModuleOp &module, std::string filepath, std::ofstream outfile(filepath, std::ios::app | std::ios::binary); uint64_t totalConstSize = 0; for (int64_t i = globalOfInterest.size() - 1; i >= 0; --i) { - KrnlGlobalOpInterface op = globalOfInterest[i]; - ArrayRef rawData = op.getBuffer(); + KrnlGlobalOp op = globalOfInterest[i]; + ArrayRef rawData = getRawData(op); // Get alignment. int64_t alignment = -1; @@ -556,11 +544,11 @@ bool extractConstantsToFile(ModuleOp &module, std::string filepath, } op.setOffsetAttr(b.getI64IntegerAttr(totalConstSize)); + op.removeValueAttr(); outfile.write(rawData.data(), rawData.size()); totalConstSize += rawData.size(); - op.removeValueAttr(); - op.freeBuffer(rawData); } + // No constant statisfying thresholds, do not store constants to file. if (totalConstSize == 0) return false; @@ -979,8 +967,7 @@ void populateKrnlToLLVMConversion(LLVMTypeConverter &typeConverter, verifyInputTensors); krnl::populateLoweringKrnlCallOpPattern(typeConverter, patterns, ctx); krnl::populateLoweringKrnlFindIndexOpPattern(typeConverter, patterns, ctx); - krnl::populateLoweringKrnlGlobalOpInterfacePattern( - typeConverter, patterns, ctx); + krnl::populateLoweringKrnlGlobalOpPattern(typeConverter, patterns, ctx); krnl::populateLoweringKrnlInstrumentOpPattern(typeConverter, patterns, ctx); krnl::populateLoweringKrnlMemcpyOpPattern(typeConverter, patterns, ctx); krnl::populateLoweringKrnlPrintOpPattern(typeConverter, patterns, ctx); diff --git a/src/Conversion/KrnlToLLVM/ConvertKrnlToLLVM.hpp b/src/Conversion/KrnlToLLVM/ConvertKrnlToLLVM.hpp index ed5258516e..2309871db4 100644 --- a/src/Conversion/KrnlToLLVM/ConvertKrnlToLLVM.hpp +++ b/src/Conversion/KrnlToLLVM/ConvertKrnlToLLVM.hpp @@ -68,9 +68,8 @@ void populateLoweringKrnlFindIndexOpPattern( mlir::LLVMTypeConverter &typeConverter, mlir::RewritePatternSet &patterns, mlir::MLIRContext *ctx); -void populateLoweringKrnlGlobalOpInterfacePattern( - mlir::LLVMTypeConverter &typeConverter, mlir::RewritePatternSet &patterns, - mlir::MLIRContext *ctx); +void populateLoweringKrnlGlobalOpPattern(mlir::LLVMTypeConverter &typeConverter, + mlir::RewritePatternSet &patterns, mlir::MLIRContext *ctx); void populateLoweringKrnlInstrumentOpPattern( mlir::LLVMTypeConverter &typeConverter, mlir::RewritePatternSet &patterns, diff --git a/src/Conversion/KrnlToLLVM/KrnlGlobalOpInterface.cpp b/src/Conversion/KrnlToLLVM/KrnlGlobal.cpp similarity index 66% rename from src/Conversion/KrnlToLLVM/KrnlGlobalOpInterface.cpp rename to src/Conversion/KrnlToLLVM/KrnlGlobal.cpp index 1e579f5595..1c13787ac0 100644 --- a/src/Conversion/KrnlToLLVM/KrnlGlobalOpInterface.cpp +++ b/src/Conversion/KrnlToLLVM/KrnlGlobal.cpp @@ -2,13 +2,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -//===------ KrnlGlobalOpInterface.cpp - Lower KrnlGlobalOpInterface -------===// +//===------ KrnlGlobal.cpp - Lower KrnlGlobalOp ---------------------------===// // -// Copyright 2019-2024 The IBM Research Authors. +// Copyright 2019-2022 The IBM Research Authors. // // ============================================================================= // -// This file lowers the KrnlGlobalOpInterface. +// This file lowers the KrnlGlobalOp operator. // //===----------------------------------------------------------------------===// @@ -35,39 +35,33 @@ namespace krnl { /// This variable is initizalied inside ConvertKrnlToLLVMPass. extern std::string EXTERNAL_CONSTANT_PREFIX; -class KrnlGlobalOpInterfaceLowering - : public OpInterfaceConversionPattern { - +class KrnlGlobalOpLowering : public ConvertToLLVMPattern { public: - using OpInterfaceConversionPattern< - KrnlGlobalOpInterface>::OpInterfaceConversionPattern; - - explicit KrnlGlobalOpInterfaceLowering( + explicit KrnlGlobalOpLowering( LLVMTypeConverter &typeConverter, MLIRContext *context) - : OpInterfaceConversionPattern(typeConverter, context) {} + : ConvertToLLVMPattern( + KrnlGlobalOp::getOperationName(), context, typeConverter) {} - LogicalResult matchAndRewrite(KrnlGlobalOpInterface op, - ArrayRef operands, + LogicalResult matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { - Location loc = op->getLoc(); - MLIRContext *context = op->getContext(); + auto krnlGlobalOp = llvm::dyn_cast(op); + Location loc = krnlGlobalOp.getLoc(); + MLIRContext *context = krnlGlobalOp.getContext(); MultiDialectBuilder create(rewriter, loc); - const LLVMTypeConverter *llvmTypeConverter = - static_cast(getTypeConverter()); // Basic type. Type llvmI8Ty = IntegerType::get(context, 8); Type llvmI8PtrTy = getPointerType(context, llvmI8Ty); // The element type of the array. - const Type type = op.getResult().getType(); + const Type type = op->getResult(0).getType(); const MemRefType memRefTy = mlir::cast(type); const Type constantElementType = - llvmTypeConverter->convertType(memRefTy.getElementType()); + typeConverter->convertType(memRefTy.getElementType()); Type globalType = constantElementType; // The llvm type of the global (example: [2 x [8 x float]]). - const auto shape = mlir::dyn_cast(op.getShape()); + const auto shape = mlir::dyn_cast(krnlGlobalOp.getShape()); if (shape.empty()) globalType = LLVM::LLVMArrayType::get(mlir::cast(globalType), 1); else { @@ -80,17 +74,16 @@ class KrnlGlobalOpInterfaceLowering LLVM::GlobalOp global; // Pointer to the raw data of the global. Value dataPtr; - // Update value attribute if needed. - op.updateValueAttr(); - if (op.getValue().has_value()) { - auto value = op.getValue().value(); + if (krnlGlobalOp.getValue().has_value()) { + auto value = krnlGlobalOp.getValue().value(); TypeSwitch(value) .Case([&](DenseResourceElementsAttr attr) { - global = lowerDenseResourceConstant(op, globalType, rewriter); + global = + lowerDenseResourceConstant(krnlGlobalOp, globalType, rewriter); }) .Case([&](DenseElementsAttr attr) { - global = lowerDenseConstant(op, globalType, rewriter); + global = lowerDenseConstant(krnlGlobalOp, globalType, rewriter); }) .Default([&](Attribute attr) { llvm_unreachable("Unsupported attribute type"); @@ -98,14 +91,15 @@ class KrnlGlobalOpInterfaceLowering dataPtr = create.llvm.addressOf(global); } else { // Data are stored on files. - global = lowerGlobalOpWithExternalFiles(op, rewriter); + global = lowerGlobalOpWithExternalFiles(krnlGlobalOp, rewriter); dataPtr = create.llvm.load(llvmI8PtrTy, create.llvm.addressOf(global)); } // Set the global alignment based on the alignment attribute if it exists, // otherwise use the module datalayout info. - krnl::setAlignment(global, op.getAlignmentAttr(), - op->getParentOfType(), rewriter, *llvmTypeConverter); + krnl::setAlignment(global, krnlGlobalOp.getAlignmentAttr(), + krnlGlobalOp->getParentOfType(), rewriter, + *getTypeConverter()); // Prepare data to be inserted into a MemRefDescriptor (a struct). MemRefDescriptor memRefDescr = @@ -121,32 +115,31 @@ class KrnlGlobalOpInterfaceLowering return mlir::cast(a.getValue()[i]).getInt(); } - LLVM::GlobalOp lowerDenseResourceConstant( - KrnlGlobalOpInterface &globalOpInterface, Type globalType, - ConversionPatternRewriter &rewriter) const { - assert(globalOpInterface.getValue().has_value() && - "Expecting KrnlGlobalOpInterface with a valid value"); - assert(mlir::isa( - globalOpInterface.getValue().value()) && - "Expecting a global with an dense resource elements attribute"); - - MLIRContext *context = globalOpInterface.getContext(); - Location loc = globalOpInterface.getLoc(); - ModuleOp module = globalOpInterface->getParentOfType(); + LLVM::GlobalOp lowerDenseResourceConstant(KrnlGlobalOp &krnlGlobalOp, + Type globalType, ConversionPatternRewriter &rewriter) const { + assert(krnlGlobalOp.getValue().has_value() && + "Expecting KrnlGlobalOp with a valid value"); + assert( + mlir::isa(krnlGlobalOp.getValue().value()) && + "Expecting a global with an dense resource elements attribute"); + + MLIRContext *context = krnlGlobalOp.getContext(); + Location loc = krnlGlobalOp.getLoc(); + ModuleOp module = krnlGlobalOp->getParentOfType(); MultiDialectBuilder create(rewriter, loc); OpBuilder::InsertionGuard insertGuard(rewriter); rewriter.setInsertionPointToStart(module.getBody()); - auto blob = mlir::cast( - globalOpInterface.getValue().value()) - .getRawHandle() - .getBlob(); + auto blob = + mlir::cast(krnlGlobalOp.getValue().value()) + .getRawHandle() + .getBlob(); assert(blob && "Expecting dense resource with a valid blob"); ArrayRef rawData = blob->getData(); // Check data size. - uint64_t sizeInBytes = computeSizeInBytes(globalOpInterface); + uint64_t sizeInBytes = computeSizeInBytes(krnlGlobalOp); assert(((uint64_t)rawData.size() == sizeInBytes) && "Data size mismatch."); StringRef data(rawData.data(), rawData.size()); @@ -154,23 +147,23 @@ class KrnlGlobalOpInterfaceLowering auto llvmArrayI8Ty = LLVM::LLVMArrayType::get(IntegerType::get(context, 8), sizeInBytes); LLVM::GlobalOp global = create.llvm.globalOp(llvmArrayI8Ty, - /*isConstant=*/true, LLVM::Linkage::Internal, - globalOpInterface.getName(), llvmStringAttr); + /*isConstant=*/true, LLVM::Linkage::Internal, krnlGlobalOp.getName(), + llvmStringAttr); LLVM_DEBUG(llvm::dbgs() << "global: " << global << "\n";); return global; } - LLVM::GlobalOp lowerDenseConstant(KrnlGlobalOpInterface &globalOpInterface, - Type globalType, ConversionPatternRewriter &rewriter) const { - assert(globalOpInterface.getValue().has_value() && - "Expecting KrnlGlobalOpInterface with a valid value"); - assert(mlir::isa(globalOpInterface.getValue().value()) && + LLVM::GlobalOp lowerDenseConstant(KrnlGlobalOp &krnlGlobalOp, Type globalType, + ConversionPatternRewriter &rewriter) const { + assert(krnlGlobalOp.getValue().has_value() && + "Expecting KrnlGlobalOp with a valid value"); + assert(mlir::isa(krnlGlobalOp.getValue().value()) && "Expecting a global with an dense elements attribute"); - Location loc = globalOpInterface.getLoc(); - ModuleOp module = globalOpInterface->getParentOfType(); - MLIRContext *context = globalOpInterface.getContext(); + Location loc = krnlGlobalOp.getLoc(); + ModuleOp module = krnlGlobalOp->getParentOfType(); + MLIRContext *context = krnlGlobalOp.getContext(); MultiDialectBuilder create(rewriter, loc); Type llvmI8Ty = IntegerType::get(context, 8); @@ -179,9 +172,9 @@ class KrnlGlobalOpInterfaceLowering rewriter.setInsertionPointToStart(module.getBody()); DenseElementsAttr denseAttr = - mlir::cast(globalOpInterface.getValue().value()); + mlir::cast(krnlGlobalOp.getValue().value()); - uint64_t sizeInBytes = computeSizeInBytes(globalOpInterface); + uint64_t sizeInBytes = computeSizeInBytes(krnlGlobalOp); LLVM::GlobalOp global; if (!(mlir::isa(denseAttr.getElementType())) && !(denseAttr.getElementType().isInteger(1)) && (!denseAttr.isSplat()) && @@ -195,15 +188,15 @@ class KrnlGlobalOpInterfaceLowering StringRef data(rawData.data(), rawData.size()); StringAttr llvmStringAttr = StringAttr::get(context, data); global = create.llvm.globalOp(llvmArrayI8Ty, - /*isConstant=*/true, LLVM::Linkage::Internal, - globalOpInterface.getName(), llvmStringAttr); + /*isConstant=*/true, LLVM::Linkage::Internal, krnlGlobalOp.getName(), + llvmStringAttr); } else { if (mlir::isa(denseAttr.getElementType())) - global = lowerStringLiteral(globalOpInterface, globalType, rewriter); + global = lowerStringLiteral(krnlGlobalOp, globalType, rewriter); else global = create.llvm.globalOp(globalType, /*isConstant=*/true, LLVM::Linkage::Internal, - globalOpInterface.getName(), globalOpInterface.getValue().value()); + krnlGlobalOp.getName(), krnlGlobalOp.getValue().value()); } LLVM_DEBUG(llvm::dbgs() << "global: " << global << "\n";); @@ -211,24 +204,21 @@ class KrnlGlobalOpInterfaceLowering } LLVM::GlobalOp lowerGlobalOpWithExternalFiles( - KrnlGlobalOpInterface &globalOpInterface, - ConversionPatternRewriter &rewriter) const { - Location loc = globalOpInterface.getLoc(); - MLIRContext *context = globalOpInterface.getContext(); - ModuleOp module = - globalOpInterface.getOperation()->getParentOfType(); + KrnlGlobalOp &krnlGlobalOp, ConversionPatternRewriter &rewriter) const { + Location loc = krnlGlobalOp.getLoc(); + MLIRContext *context = krnlGlobalOp.getContext(); + ModuleOp module = krnlGlobalOp.getOperation()->getParentOfType(); MultiDialectBuilder create(rewriter, loc); Type llvmI8Ty = IntegerType::get(context, 8); Type llvmI8PtrTy = getPointerType(context, llvmI8Ty); Type llvmI64Ty = IntegerType::get(context, 64); - auto offset = globalOpInterface.getOffset(); - assert( - offset.has_value() && "Missing offset value in KrnlGlobalOpInterface"); + auto offset = krnlGlobalOp.getOffset(); + assert(offset.has_value() && "Missing offset value in KrnlGlobalOp"); // Data is store in `constants.bin` at offset. - std::string constantName = globalOpInterface.getName().str(); + std::string constantName = krnlGlobalOp.getName().str(); // Emit globals at the begining of the module. OpBuilder::InsertionGuard insertGuard(rewriter); @@ -256,14 +246,14 @@ class KrnlGlobalOpInterfaceLowering return global; } - uint64_t computeSizeInBytes(KrnlGlobalOpInterface &globalOpInterface) const { + uint64_t computeSizeInBytes(KrnlGlobalOp &krnlGlobalOp) const { // Compute total number of elements. - const auto shape = mlir::dyn_cast(globalOpInterface.getShape()); + const auto shape = mlir::dyn_cast(krnlGlobalOp.getShape()); uint64_t numElements = 1; for (unsigned int i = 0; i < shape.size(); ++i) numElements *= ArrayAttrIntVal(shape, i); - const auto type = globalOpInterface.getResult().getType(); + const auto type = krnlGlobalOp.getResult().getType(); const auto memRefTy = mlir::cast(type); // Special handling for bool. @@ -277,9 +267,8 @@ class KrnlGlobalOpInterfaceLowering MemRefDescriptor createMemRefDescriptor(Value address, MemRefType memRefType, Location loc, OpBuilder &builder) const { Type elementType = memRefType.getElementType(); - const LLVMTypeConverter *llvmTypeConverter = - static_cast(getTypeConverter()); - Type llvmElemType = llvmTypeConverter->convertType(elementType); + const LLVMTypeConverter &typeConverter = *getTypeConverter(); + Type llvmElemType = typeConverter.convertType(elementType); MLIRContext *context = builder.getContext(); MultiDialectBuilder create(builder, loc); @@ -289,21 +278,21 @@ class KrnlGlobalOpInterfaceLowering Value bitCastOp = create.llvm.bitcast(ptrType, address); // Create llvm MemRef from original MemRef and fill the data pointers. return MemRefDescriptor::fromStaticShape( - builder, loc, *llvmTypeConverter, memRefType, bitCastOp); + builder, loc, typeConverter, memRefType, bitCastOp); } - // Generate a global string for each globalOpInterface string value, and store + // Generate a global string for each krnlGlobalOp string value, and store // the address of the global strings into an array. Return the array address. - LLVM::GlobalOp lowerStringLiteral(KrnlGlobalOpInterface &globalOpInterface, - Type globalType, OpBuilder &builder) const { - assert(mlir::isa(globalOpInterface.getValue().value()) && + LLVM::GlobalOp lowerStringLiteral( + KrnlGlobalOp &krnlGlobalOp, Type globalType, OpBuilder &builder) const { + assert(mlir::isa(krnlGlobalOp.getValue().value()) && "Expecting a dense value"); - Location loc = globalOpInterface.getLoc(); + Location loc = krnlGlobalOp.getLoc(); MultiDialectBuilder create(builder, loc); DenseElementsAttr denseAttr = - mlir::cast(globalOpInterface.getValue().value()); + mlir::cast(krnlGlobalOp.getValue().value()); Type i8PtrType = getI8PointerType(builder.getContext()); @@ -333,14 +322,14 @@ class KrnlGlobalOpInterfaceLowering auto llvmArrayI8Ty = LLVM::LLVMArrayType::get(i8Type, totalSize); LLVM::GlobalOp globalStr = create.llvm.globalOp(llvmArrayI8Ty, /*isConstant=*/true, LLVM::Linkage::Internal, - "om.strArray." + globalOpInterface.getName().str(), llvmStringAttr); + "om.strArray." + krnlGlobalOp.getName().str(), llvmStringAttr); // Generate an LLVM GlobalOps with an initializer region containing one // block. auto arrayType = LLVM::LLVMArrayType::get(i8PtrType, offsets.size()); auto global = create.llvm.globalOp(arrayType, - /*isConstant=*/true, LLVM::Linkage::Internal, - globalOpInterface.getName(), Attribute()); + /*isConstant=*/true, LLVM::Linkage::Internal, krnlGlobalOp.getName(), + Attribute()); Region ®ion = global.getInitializerRegion(); Block *block = builder.createBlock(®ion); @@ -366,10 +355,9 @@ class KrnlGlobalOpInterfaceLowering } }; -void populateLoweringKrnlGlobalOpInterfacePattern( - LLVMTypeConverter &typeConverter, RewritePatternSet &patterns, - MLIRContext *ctx) { - patterns.insert(typeConverter, ctx); +void populateLoweringKrnlGlobalOpPattern(LLVMTypeConverter &typeConverter, + RewritePatternSet &patterns, MLIRContext *ctx) { + patterns.insert(typeConverter, ctx); } } // namespace krnl diff --git a/src/Conversion/ONNXToKrnl/Math/Reduction.cpp b/src/Conversion/ONNXToKrnl/Math/Reduction.cpp index 34336d1030..d49e1bd058 100644 --- a/src/Conversion/ONNXToKrnl/Math/Reduction.cpp +++ b/src/Conversion/ONNXToKrnl/Math/Reduction.cpp @@ -664,7 +664,8 @@ struct ONNXReductionOpLowering : public OpConversionPattern { ////////////////////////////////////////////////////////////////////// // Reduction over all dimensions to a scalar value. - bool fullReduction = hasNoAxes || (rawAxesIE.size() == inRank); + bool fullReduction = + hasNoAxes || (rawAxesIE.size() == static_cast(inRank)); if (fullReduction && !isKeepdims && enableSIMD) { Value alloc, none; if (emitFullSIMDReductionFor( diff --git a/src/Dialect/Krnl/CMakeLists.txt b/src/Dialect/Krnl/CMakeLists.txt index c3c7bf8991..683e4500dc 100644 --- a/src/Dialect/Krnl/CMakeLists.txt +++ b/src/Dialect/Krnl/CMakeLists.txt @@ -18,7 +18,6 @@ add_onnx_mlir_library(OMKrnlOps DEPENDS OMKrnlIncGen OMSpecializedKernelOpInterface - OMKrnlGlobalOpInterface LINK_LIBS PUBLIC OMCompilerOptions diff --git a/src/Dialect/Krnl/Krnl.td b/src/Dialect/Krnl/Krnl.td index 1d5a015d29..c8220dfc53 100644 --- a/src/Dialect/Krnl/Krnl.td +++ b/src/Dialect/Krnl/Krnl.td @@ -27,7 +27,6 @@ include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/Interfaces/ViewLikeInterface.td" include "mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td" include "src/Interface/SpecializedKernelOpInterface.td" -include "src/Interface/KrnlGlobalOpInterface.td" def Krnl_Dialect : Dialect { let name = "krnl"; @@ -407,8 +406,7 @@ def KrnlMemcpyOp : Op, MemRefsNormalizable]> { +def KrnlGlobalOp : Op { let summary = "Krnl global operation"; let description = [{ Operation for holding global data values. A global constant can have a diff --git a/src/Dialect/Krnl/KrnlOps.cpp b/src/Dialect/Krnl/KrnlOps.cpp index bdcf2bffba..cec7b2d94d 100644 --- a/src/Dialect/Krnl/KrnlOps.cpp +++ b/src/Dialect/Krnl/KrnlOps.cpp @@ -12,14 +12,12 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/Affine/Analysis/Utils.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Math/IR/Math.h" #include "mlir/Dialect/SCF/IR/SCF.h" #include "mlir/Dialect/Shape/IR/Shape.h" #include "mlir/IR/DialectImplementation.h" -#include "mlir/IR/DialectResourceBlobManager.h" #include "llvm/ADT/TypeSwitch.h" #include "mlir/IR/Value.h" @@ -814,34 +812,6 @@ MutableOperandRange KrnlSpecializedKernel::getLoopRefs() { return getLoopsMutable(); } -ArrayRef KrnlGlobalOp::getBuffer() { - ArrayRef ret; - std::vector attrData; - if (getValueAttr()) { - int64_t sizeInBytes = getBufferSize(); - char *rawData = (char *)malloc(sizeInBytes); - auto valueAttr = getValue().value(); - getRawData(valueAttr, attrData); - memcpy(rawData, attrData.data(), sizeInBytes); - ret = llvm::ArrayRef(rawData, sizeInBytes); - } - return ret; -} - -uint64_t KrnlGlobalOp::getBufferSize() { - const Type type = getOperation()->getResults()[0].getType(); - const MemRefType memRefTy = mlir::cast(type); - auto sizeInBytes = affine::getIntOrFloatMemRefSizeInBytes(memRefTy); - return sizeInBytes.has_value() ? sizeInBytes.value() : 0; -} - -void KrnlGlobalOp::freeBuffer(ArrayRef rawData) { - free(const_cast(rawData.data())); - return; -} - -void KrnlGlobalOp::updateValueAttr() {} - //===----------------------------------------------------------------------===// // KrnlMatMulOp //===----------------------------------------------------------------------===// diff --git a/src/Dialect/Krnl/KrnlOps.hpp b/src/Dialect/Krnl/KrnlOps.hpp index fcf48a395d..661fa7576d 100644 --- a/src/Dialect/Krnl/KrnlOps.hpp +++ b/src/Dialect/Krnl/KrnlOps.hpp @@ -21,7 +21,6 @@ #include "src/Dialect/Krnl/KrnlHelper.hpp" #include "src/Dialect/Krnl/KrnlTypes.hpp" -#include "src/Interface/KrnlGlobalOpInterface.hpp" #include "src/Interface/SpecializedKernelOpInterface.hpp" #include "src/Dialect/Krnl/KrnlDialect.hpp.inc" diff --git a/src/Dialect/ONNX/ElementsAttr/DisposableElementsAttr.hpp b/src/Dialect/ONNX/ElementsAttr/DisposableElementsAttr.hpp index 3739904c17..cabfe58c02 100644 --- a/src/Dialect/ONNX/ElementsAttr/DisposableElementsAttr.hpp +++ b/src/Dialect/ONNX/ElementsAttr/DisposableElementsAttr.hpp @@ -116,6 +116,11 @@ class DisposableElementsAttr return *this ? mlir::cast(*this) : nullptr; } + // Clears the buffer payload shared_ptr which decreases the reference count + // and, if it reaches zero, frees or closes the underlying MemoryBuffer's + // heap allocation or file. Called from DisposablePool. + void dispose(); + private: // Called from DisposablePool who calls with a unique id and records the // created instance. @@ -123,11 +128,6 @@ class DisposableElementsAttr BType bufferBType, ArrayRef strides, const Buffer &buffer, Transformer transformer); - // Clears the buffer payload shared_ptr which decreases the reference count - // and, if it reaches zero, frees or closes the underlying MemoryBuffer's - // heap allocation or file. Called from DisposablePool. - void dispose(); - public: //===--------------------------------------------------------------------===// // Instance properties: @@ -259,6 +259,12 @@ class DisposableElementsAttr template void readArray(MutableArrayRef dst) const; + // Returns a pointer to the underlying data as a flat byte array, if + // everything aligns, otherwise makes and returns a copy. + // If the element type is bool the data holds one byte (with value 0 or 1) per + // bool (contrary to how DenseElementsAttr::getRawData() bit packs bools). + onnx_mlir::ArrayBuffer getRawBytes() const; + // Returns a pointer to the underlying data as a flat WideNum array, if // everything aligns, otherwise makes and returns a copy. onnx_mlir::ArrayBuffer getWideNums() const; @@ -313,12 +319,6 @@ class DisposableElementsAttr // bool (contrary to how DenseElementsAttr::getRawData() bit packs bools). void readRawBytes(MutableArrayRef dst) const; - // Returns a pointer to the underlying data as a flat byte array, if - // everything aligns, otherwise makes and returns a copy. - // If the element type is bool the data holds one byte (with value 0 or 1) per - // bool (contrary to how DenseElementsAttr::getRawData() bit packs bools). - onnx_mlir::ArrayBuffer getRawBytes() const; - }; // class DisposableElementsAttr // Include template implementations. diff --git a/src/Dialect/ONNX/ONNXOps/Canonicalize.cpp b/src/Dialect/ONNX/ONNXOps/Canonicalize.cpp index c29eabfcc4..f2e5aaafd9 100644 --- a/src/Dialect/ONNX/ONNXOps/Canonicalize.cpp +++ b/src/Dialect/ONNX/ONNXOps/Canonicalize.cpp @@ -743,7 +743,6 @@ class LoopOpRewriteMaxTripCountPattern : public OpRewritePattern { bool isDefinedByIntegerConstantOp(Value v) const { if (mlir::isa(v)) return false; - Operation *definingOp = v.getDefiningOp(); if (mlir::isa( mlir::cast(v.getType()).getElementType()) && isDenseONNXConstant(v)) diff --git a/src/Dialect/ONNX/ONNXOps/OpHelper.cpp b/src/Dialect/ONNX/ONNXOps/OpHelper.cpp index 72479a53ab..520de56339 100644 --- a/src/Dialect/ONNX/ONNXOps/OpHelper.cpp +++ b/src/Dialect/ONNX/ONNXOps/OpHelper.cpp @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#include "mlir/IR/DialectResourceBlobManager.h" #include "mlir/IR/TypeUtilities.h" #include "llvm/ADT/TypeSwitch.h" #include "llvm/Support/Path.h" @@ -753,29 +752,6 @@ bool hasIntegerPowerExponent(ONNXPowOp *op, int64_t &exponentValue) { return false; } -/// Get raw data from a dense attribute. -void getRawData(Attribute dataAttr, std::vector &data) { - TypeSwitch(dataAttr) - .Case([&](DenseElementsAttr denseAttr) { - if (!denseAttr.isSplat()) { - data = denseAttr.getRawData(); - } else { - ShapedType denseShapeType = - mlir::cast(denseAttr.getType()); - std::vector rawData = denseAttr.getRawData(); - int64_t numElements = denseShapeType.getNumElements(); - for (int i = 0; i < numElements; i++) - data.insert(data.end(), rawData.begin(), rawData.end()); - } - }) - .Case( - [&](DenseResourceElementsAttr denseResourceAttr) { - data = denseResourceAttr.getRawHandle().getBlob()->getData(); - }) - .Default( - [&](Attribute attr) { llvm_unreachable("Unsupported data type."); }); -} - //===----------------------------------------------------------------------===// // Support for ReshapeOp. //===----------------------------------------------------------------------===// diff --git a/src/Dialect/ONNX/ONNXOps/OpHelper.hpp b/src/Dialect/ONNX/ONNXOps/OpHelper.hpp index 278a454313..b084ad5cd6 100644 --- a/src/Dialect/ONNX/ONNXOps/OpHelper.hpp +++ b/src/Dialect/ONNX/ONNXOps/OpHelper.hpp @@ -261,9 +261,6 @@ bool isScalarTensor(mlir::Value v); bool hasIntegerPowerExponent(mlir::ONNXPowOp *op, int64_t &exponentValue); -/// Get raw data from a dense attribute. -void getRawData(mlir::Attribute dataAttr, std::vector &data); - //===----------------------------------------------------------------------===// // Support for dim operations. //===----------------------------------------------------------------------===// diff --git a/src/Interface/CMakeLists.txt b/src/Interface/CMakeLists.txt index 21b76d0f31..07a1eb6873 100644 --- a/src/Interface/CMakeLists.txt +++ b/src/Interface/CMakeLists.txt @@ -5,7 +5,6 @@ add_onnx_mlir_interface(ShapeHelperOpInterface) add_onnx_mlir_interface(ResultTypeInferenceOpInterface) add_onnx_mlir_interface(HasOnnxSubgraphOpInterface) add_onnx_mlir_interface(SpecializedKernelOpInterface) -add_onnx_mlir_interface(KrnlGlobalOpInterface) add_onnx_mlir_library(OMShapeInferenceOpInterface ShapeInferenceOpInterface.cpp @@ -62,14 +61,3 @@ add_onnx_mlir_library(OMSpecializedKernelOpInterface MLIRIR LLVMSupport ) - -add_onnx_mlir_library(OMKrnlGlobalOpInterface - KrnlGlobalOpInterface.cpp - - DEPENDS - OMKrnlGlobalOpInterfaceIncGen - - LINK_LIBS PUBLIC - MLIRIR - LLVMSupport - ) diff --git a/src/Interface/KrnlGlobalOpInterface.cpp b/src/Interface/KrnlGlobalOpInterface.cpp deleted file mode 100644 index f54c6222c6..0000000000 --- a/src/Interface/KrnlGlobalOpInterface.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - */ - -//===-------------------- KrnlGlobalOpInterface.cpp -----------------------===// -//===---------------- KrnlGlobalOp Interface Definition -------------------===// -// -// Copyright 2024 The IBM Research Authors. -// -// ============================================================================= -// -// This file contains the definition of the Constant Op Interface. -// -//===----------------------------------------------------------------------===// - -#include "KrnlGlobalOpInterface.hpp" - -using namespace mlir; - -//===----------------------------------------------------------------------===// -// KrnlGlobal Op Interface -//===----------------------------------------------------------------------===// - -#include "src/Interface/KrnlGlobalOpInterface.cpp.inc" diff --git a/src/Interface/KrnlGlobalOpInterface.hpp b/src/Interface/KrnlGlobalOpInterface.hpp deleted file mode 100644 index c9adafca14..0000000000 --- a/src/Interface/KrnlGlobalOpInterface.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - */ - -//===-------------------- KrnlGlobalOpInterfaceo.hpp ----------------------===// -//===---------------- KrnlGlobal Op Interface Definition ------------------===// -// -// Copyright 2024 The IBM Research Authors. -// -// ============================================================================= -// -// This file contains the definition of the KrnlGlobal Op Interface. -// -//===----------------------------------------------------------------------===// - -#ifndef ONNX_MLIR_KRNLGLOBALOP_INTERFACE_H -#define ONNX_MLIR_KRNLGLOBALOP_INTERFACE_H - -#include -#include - -#include "mlir/IR/OpDefinition.h" - -/// Include the auto-generated declarations. -#include "src/Interface/KrnlGlobalOpInterface.hpp.inc" - -#endif diff --git a/src/Interface/KrnlGlobalOpInterface.td b/src/Interface/KrnlGlobalOpInterface.td deleted file mode 100644 index 71e2c1a918..0000000000 --- a/src/Interface/KrnlGlobalOpInterface.td +++ /dev/null @@ -1,88 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 - -//===-------------------- KrnlGlobalOpInterface.hpp -----------------------===// -//===---------------- KrnlGlobal Op Interface Definition ------------------===// -// -// Copyright 2024 The IBM Research Authors. -// -// ============================================================================= -// -// This file contains the TableGen definition of the Constant Op -// Interface Definition. -// -//===----------------------------------------------------------------------===// - -#ifdef KRNLGLOBAL_OP_INTERFACE -#else -#define KRNLGLOBAL_OP_INTERFACE - -include "mlir/IR/OpBase.td" - -def KrnlGlobalOpInterface : OpInterface<"KrnlGlobalOpInterface"> { - let description = [{ - A KrnlGlobalOp-like operation is one that holds global constant value. It has - `name` attribute, `shape` attribute, `offset` attribute, and `alighnment` - attribute. Its content is stored in the `value` attribute, which can be - converted when retrieving. - }]; - - let methods = [ - InterfaceMethod<"Get the buffer for the constant value from value attribute. " - "If conversions are required to get the buffer. It should be " - "done in this method. The constant value is stored in newly " - "allocated buffer. The buffer needs to be freed afte use by " - "using `freeBuffer()`.", - "::mlir::ArrayRef", "getBuffer", (ins ) - >, - InterfaceMethod<"Get the size of the buffer. ", - "uint64_t", "getBufferSize", (ins ) - >, - InterfaceMethod<"Free the buffer for the constant value retrieved from value " - "attribute.", - "void", "freeBuffer", (ins "::mlir::ArrayRef": $buffer) - >, - InterfaceMethod<"Update the `value` attribute by converting existing `value` " - "attribute. Assume to use getBuffer(), setValueAttr(), and " - "freeBuffer() in this function.", - "void", "updateValueAttr", (ins ) - >, - InterfaceMethod<"Get the value from the attribute.", - "std::optional", "getValue", (ins ) - >, - InterfaceMethod<"Get the `value` attribute.", - "Attribute", "getValueAttr", (ins ) - >, - InterfaceMethod<"Remove value attribute.", - "Attribute", "removeValueAttr", (ins ) - >, - InterfaceMethod<"Get the `alignment` attribute.", - "std::optional", "getAlignment", (ins ) - >, - InterfaceMethod<"Get the attribute for the alignment.", - "IntegerAttr", "getAlignmentAttr", (ins ) - >, - InterfaceMethod<"Get the `shape` attribute.", - "::mlir::Attribute", "getShape", (ins ) - >, - InterfaceMethod<"Get the `name` attribute.", - "::mlir::StringRef", "getName", (ins ) - >, - InterfaceMethod<"Set the offset to the attribute.", - "void", "setOffsetAttr", (ins "::mlir::IntegerAttr": $attr) - >, - InterfaceMethod<"Get the `offset` attribute.", - "std::optional", "getOffset", (ins ) - > - ]; - - let extraClassDeclaration = [{ - /// Return the single result of this op. - ::mlir::Value getResult() { - return getOperation()->getResult(0); - } - }]; - - let cppNamespace = "::mlir"; -} - -#endif // KRNLGLOBAL_OP_INTERFACE diff --git a/test/mlir/accelerators/nnpa/conversion/device-placement/emit-zhighir.mlir b/test/mlir/accelerators/nnpa/conversion/device-placement/emit-zhighir.mlir index a03c59b2f4..0667e0e3b0 100644 --- a/test/mlir/accelerators/nnpa/conversion/device-placement/emit-zhighir.mlir +++ b/test/mlir/accelerators/nnpa/conversion/device-placement/emit-zhighir.mlir @@ -1,5 +1,5 @@ -// RUN: onnx-mlir --EmitZHighIR --mcpu=z16 --maccel=NNPA --disable-constant-prop=true --printIR %s | FileCheck %s +//&& RUN: onnx-mlir --EmitZHighIR --mcpu=z16 --maccel=NNPA --disable-constant-prop=true --printIR %s | FileCheck %s // Note that, we intentionally add `device=cpu` into onnx.Gemm to force it run on CPU. module { @@ -39,13 +39,13 @@ module { // CHECK-DAG: [[VAR_8_:%.+]] = "onnx.Transpose"([[VAR_2_]]) {perm = [2, 3, 1, 0]} : (tensor<8x1x5x5xf32>) -> tensor<5x5x1x8xf32> // CHECK-NOT: separator of consecutive DAGs // CHECK-DAG: [[VAR_9_:%.+]] = "zhigh.Stick"([[VAR_8_]]) {layout = "HWCK"} : (tensor<5x5x1x8xf32>) -> tensor<5x5x1x8xf16, #zhigh.layout<{dataLayout = "HWCK"}>> -// CHECK-DAG: [[VAR_10_:%.+]] = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<[-0.161539719, -0.433835655, 0.091641359, -0.0168522168, -0.0650264397, -0.131737873, 0.0204175506, -0.121110231]> : tensor<8xf32>} : () -> tensor<8xf16, #zhigh.layout<{dataLayout = "1D"}>> +// CHECK-DAG: [[VAR_10_:%.+]] = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<4096xi8>} : () -> tensor<8xf16, #zhigh.layout<{dataLayout = "1D"}>> // CHECK: [[VAR_11_:%.+]] = "zhigh.Conv2D"([[VAR_7_]], [[VAR_9_]], [[VAR_10_]]) {act_func = "ACT_RELU", kernel_shape = [5, 5], padding_type = "SAME_PADDING", strides = [1, 1]} : (tensor<1x28x28x1xf16, #zhigh.layout<{dataLayout = "NHWC"}>>, tensor<5x5x1x8xf16, #zhigh.layout<{dataLayout = "HWCK"}>>, tensor<8xf16, #zhigh.layout<{dataLayout = "1D"}>>) -> tensor<1x28x28x8xf16, #zhigh.layout<{dataLayout = "NHWC"}>> // CHECK-DAG: [[VAR_12_:%.+]] = "zhigh.MaxPool2D"([[VAR_11_]]) {kernel_shape = [2, 2], padding_type = "VALID_PADDING", strides = [2, 2]} : (tensor<1x28x28x8xf16, #zhigh.layout<{dataLayout = "NHWC"}>>) -> tensor<1x14x14x8xf16, #zhigh.layout<{dataLayout = "NHWC"}>> // CHECK-DAG: [[VAR_13_:%.+]] = "onnx.Transpose"([[VAR_1_]]) {perm = [2, 3, 1, 0]} : (tensor<16x8x5x5xf32>) -> tensor<5x5x8x16xf32> // CHECK-NOT: separator of consecutive DAGs // CHECK-DAG: [[VAR_14_:%.+]] = "zhigh.Stick"([[VAR_13_]]) {layout = "HWCK"} : (tensor<5x5x8x16xf32>) -> tensor<5x5x8x16xf16, #zhigh.layout<{dataLayout = "HWCK"}>> -// CHECK-DAG: [[VAR_15_:%.+]] = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<[-0.0822488219, -0.108868778, -0.141039595, -0.204869166, -0.17913565, -0.215438381, -0.133805066, -0.195724562, -0.268250644, -0.258212209, -0.0761560649, 0.0132841459, -0.00444464432, -0.414740831, -0.17879115, -0.0386558883]> : tensor<16xf32>} : () -> tensor<16xf16, #zhigh.layout<{dataLayout = "1D"}>> +// CHECK-DAG: [[VAR_15_:%.+]] = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<4096xi8>} : () -> tensor<16xf16, #zhigh.layout<{dataLayout = "1D"}>> // CHECK: [[VAR_16_:%.+]] = "zhigh.Conv2D"([[VAR_12_]], [[VAR_14_]], [[VAR_15_]]) {act_func = "ACT_RELU", kernel_shape = [5, 5], padding_type = "SAME_PADDING", strides = [1, 1]} : (tensor<1x14x14x8xf16, #zhigh.layout<{dataLayout = "NHWC"}>>, tensor<5x5x8x16xf16, #zhigh.layout<{dataLayout = "HWCK"}>>, tensor<16xf16, #zhigh.layout<{dataLayout = "1D"}>>) -> tensor<1x14x14x16xf16, #zhigh.layout<{dataLayout = "NHWC"}>> // CHECK: [[VAR_17_:%.+]] = "zhigh.MaxPool2D"([[VAR_16_]]) {kernel_shape = [3, 3], padding_type = "VALID_PADDING", strides = [3, 3]} : (tensor<1x14x14x16xf16, #zhigh.layout<{dataLayout = "NHWC"}>>) -> tensor<1x4x4x16xf16, #zhigh.layout<{dataLayout = "NHWC"}>> // CHECK: [[VAR_18_:%.+]] = "zhigh.Unstick"([[VAR_17_]]) : (tensor<1x4x4x16xf16, #zhigh.layout<{dataLayout = "NHWC"}>>) -> tensor<1x16x4x4xf32> diff --git a/test/mlir/accelerators/nnpa/conversion/lower-all-to-llvm.mlir b/test/mlir/accelerators/nnpa/conversion/lower-all-to-llvm.mlir index 4100b41d9e..2307680415 100644 --- a/test/mlir/accelerators/nnpa/conversion/lower-all-to-llvm.mlir +++ b/test/mlir/accelerators/nnpa/conversion/lower-all-to-llvm.mlir @@ -478,4 +478,3 @@ func.func @test_call_zdnn_batchnorm() -> () { // CHECK-LABEL: test_call_zdnn_batchnorm // CHECK: {{.*}} = llvm.call @zdnn_batchnorm(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i32 } - diff --git a/test/mlir/accelerators/nnpa/conversion/lower-to-llvm-be/lit.local.cfg b/test/mlir/accelerators/nnpa/conversion/lower-to-llvm-be/lit.local.cfg deleted file mode 100644 index ac7f7ec3e6..0000000000 --- a/test/mlir/accelerators/nnpa/conversion/lower-to-llvm-be/lit.local.cfg +++ /dev/null @@ -1,6 +0,0 @@ -if sys.byteorder == "little": - config.unsupported = True -else: - config.unsupported = False - -root = config.root diff --git a/test/mlir/accelerators/nnpa/conversion/lower-to-llvm-be/lower-all-to-llvm_be.mlir b/test/mlir/accelerators/nnpa/conversion/lower-to-llvm-be/lower-all-to-llvm_be.mlir deleted file mode 100644 index 0a5c78240a..0000000000 --- a/test/mlir/accelerators/nnpa/conversion/lower-to-llvm-be/lower-all-to-llvm_be.mlir +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: onnx-mlir-opt --mcpu=z16 --maccel=NNPA --convert-krnl-to-llvm %s -split-input-file | FileCheck %s - -// ----- - -func.func @test_stickifiedconstant() -> memref<1x1x1x1x32x64xf16> { - %0 = "zlow.stickifiedConstant"() {alignment = 4096 : i64, layout = "2D", name = "constant_stickify_0", offset = 0 : i64, shape = [1, 1, 1, 1, 32, 64], stickified = false, value = dense<[[0.000000e+00, 1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00, 5.000000e+00]]> : tensor<2x3xf32>} : () -> memref<1x1x1x1x32x64xf16> - return %0 : memref<1x1x1x1x32x64xf16> - - // CHECK: llvm.mlir.global internal constant @constant_stickify_0("\00\00>\00@\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00A\00B\00B\80\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") {addr_space = 0 : i32, alignment = 4096 : i64} - -} - -// ----- - -func.func @test_stickifiedconstant_allzero() -> memref<1x1x1x1x32x64xf16> { - %0 = "zlow.stickifiedConstant"() {alignment = 4096 : i64, layout = "2D", name = "constant_stickify_0", offset = 0 : i64, shape = [1, 1, 1, 1, 32, 64], stickified = true, value = dense<0.000000e+00> : tensor<1x1x1x32x64xf16>} : () -> memref<1x1x1x1x32x64xf16> - return %0 : memref<1x1x1x1x32x64xf16> - - // CHECK: llvm.mlir.global internal constant @constant_stickify_0("\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") {addr_space = 0 : i32, alignment = 4096 : i64} - -} diff --git a/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/conv.mlir b/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/conv.mlir index c409d1f9fd..2d2983ba07 100644 --- a/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/conv.mlir +++ b/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/conv.mlir @@ -189,7 +189,7 @@ func.func @conv_same_padding_no_bias_unknown_dims(%arg0: tensor<1x32x32x3xf16, # // CHECK: krnl.store [[VAR_c1_i64_]], [[RES_1_]]{{.}}[[VAR_c4_]]{{.}} : memref<7xi64> // CHECK: krnl.store [[VAR_c32_i64_]], [[RES_1_]]{{.}}[[VAR_c5_]]{{.}} : memref<7xi64> // CHECK: krnl.store [[VAR_c32_i64_]], [[RES_1_]]{{.}}[[VAR_c6_]]{{.}} : memref<7xi64> -// CHECK: [[VAR_2_:%.+]] = "zlow.stickifiedConstant"() {alignment = 4096 : i64, name = "constant_stickify_0", offset = 0 : i64, shape = [1, 1, 1, 1, 32, 64], stickified = true, value = dense<0.000000e+00> : memref<1x1x1x1x32x64xf16>} : () -> memref<1x1x1x1x32x64xf16> +// CHECK: [[VAR_2_:%.+]] = "krnl.global"() {alignment = 4096 : i64, name = "constant_stickify_0", shape = [1, 1, 1, 1, 32, 64], value = dense_resource : tensor<4096xi8>} : () -> memref<1x1x1x1x32x64xf16> // CHECK: "zlow.conv2d"([[PARAM_0_]], [[PARAM_1_]], [[VAR_2_]], [[RES_1_]], [[RES_]]) {act_func = "ACT_NONE", kernel_shape = [2, 2], padding_type = "SAME_PADDING", strides = [1, 1]} : (memref<1x32x32x3xf16, #map>, memref<2x2x3x1xf16, #map1>, memref<1x1x1x1x32x64xf16>, memref<7xi64>, memref<1x32x32x1xf16, #map>) -> () // CHECK: return [[RES_]] : memref<1x32x32x1xf16, #map> // CHECK: } diff --git a/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/gru.mlir b/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/gru.mlir index c705168d4d..b828da2b80 100644 --- a/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/gru.mlir +++ b/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/gru.mlir @@ -220,8 +220,8 @@ func.func @gru_no_input_and_hidden_biases(%input : tensor // CHECK: krnl.store [[VAR_c7_i64_]], [[RES_1_]]{{.}}[[VAR_c3_]]{{.}} : memref<5xi64> // CHECK: krnl.store [[VAR_c9_i64_]], [[RES_1_]]{{.}}[[VAR_c4_]]{{.}} : memref<5xi64> -// CHECK-DAG: [[VAR_2_:%.+]] = "zlow.stickifiedConstant"() {alignment = 4096 : i64, name = "constant_stickify_0", offset = 0 : i64, shape = [1, 3, 1, 1, 32, 64], stickified = true, value = dense<0.000000e+00> : memref<1x3x1x1x32x64xf16>} : () -> memref<1x3x1x1x32x64xf16> -// CHECK-DAG: [[VAR_3_:%.+]] = "zlow.stickifiedConstant"() {alignment = 4096 : i64, name = "constant_stickify_1", offset = 0 : i64, shape = [1, 3, 1, 1, 32, 64], stickified = true, value = dense<0.000000e+00> : memref<1x3x1x1x32x64xf16>} : () -> memref<1x3x1x1x32x64xf16> +// CHECK-DAG: [[VAR_2_:%.+]] = "krnl.global"() {alignment = 4096 : i64, name = "constant_stickify_0", shape = [1, 3, 1, 1, 32, 64], value = dense_resource : tensor<12288xi8>} : () -> memref<1x3x1x1x32x64xf16> +// CHECK-DAG: [[VAR_3_:%.+]] = "krnl.global"() {alignment = 4096 : i64, name = "constant_stickify_1", shape = [1, 3, 1, 1, 32, 64], value = dense_resource : tensor<12288xi8>} : () -> memref<1x3x1x1x32x64xf16> // CHECK-DAG: [[VAR_dim_2_:%.+]] = memref.dim [[PARAM_0_]], [[VAR_c0_]] : memref // CHECK-DAG: [[VAR_dim_3_:%.+]] = memref.dim [[PARAM_0_]], [[VAR_c1_]] : memref // CHECK-NOT: separator of consecutive DAGs diff --git a/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/lstm.mlir b/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/lstm.mlir index a31d70231e..e63d5cee97 100644 --- a/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/lstm.mlir +++ b/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/lstm.mlir @@ -357,8 +357,8 @@ func.func @lstm_no_input_and_hidden_biases(%input : tensor // CHECK: krnl.store [[VAR_c7_i64_]], [[RES_2_]]{{.}}[[VAR_c3_]]{{.}} : memref<5xi64> // CHECK: krnl.store [[VAR_c9_i64_]], [[RES_2_]]{{.}}[[VAR_c4_]]{{.}} : memref<5xi64> -// CHECK-DAG: [[VAR_2_:%.+]] = "zlow.stickifiedConstant"() {alignment = 4096 : i64, name = "constant_stickify_0", offset = 0 : i64, shape = [1, 4, 1, 1, 32, 64], stickified = true, value = dense<0.000000e+00> : memref<1x4x1x1x32x64xf16>} : () -> memref<1x4x1x1x32x64xf16> -// CHECK-DAG: [[VAR_3_:%.+]] = "zlow.stickifiedConstant"() {alignment = 4096 : i64, name = "constant_stickify_1", offset = 0 : i64, shape = [1, 4, 1, 1, 32, 64], stickified = true, value = dense<0.000000e+00> : memref<1x4x1x1x32x64xf16>} : () -> memref<1x4x1x1x32x64xf16> +// CHECK-DAG: [[VAR_2_:%.+]] = "krnl.global"() {alignment = 4096 : i64, name = "constant_stickify_0", shape = [1, 4, 1, 1, 32, 64], value = dense_resource : tensor<16384xi8>} : () -> memref<1x4x1x1x32x64xf16> +// CHECK-DAG: [[VAR_3_:%.+]] = "krnl.global"() {alignment = 4096 : i64, name = "constant_stickify_1", shape = [1, 4, 1, 1, 32, 64], value = dense_resource : tensor<16384xi8>} : () -> memref<1x4x1x1x32x64xf16> // CHECK-DAG: [[VAR_dim_3_:%.+]] = memref.dim [[PARAM_0_]], [[VAR_c0_]] : memref // CHECK-DAG: [[VAR_dim_4_:%.+]] = memref.dim [[PARAM_0_]], [[VAR_c1_]] : memref // CHECK-NOT: separator of consecutive DAGs diff --git a/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/stickified-constant.mlir b/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/stickified-constant.mlir index b0188969d0..6d961c2dea 100644 --- a/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/stickified-constant.mlir +++ b/test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/stickified-constant.mlir @@ -2,17 +2,24 @@ module { func.func @remove_stick_2d() -> tensor<2x3xf32> { - %0 = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<[[0., 1., 2.], [3., 4., 5.]]> : tensor<2x3xf32>} : () -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "2D"}>> + %0 = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<4096xi8>} : () -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "2D"}>> %1 = "zhigh.Unstick"(%0) : (tensor<2x3xf16, #zhigh.layout<{dataLayout = "2D"}>>) -> tensor<2x3xf32> return %1 : tensor<2x3xf32> } } +{-# + dialect_resources: { + builtin: { + zhigh: "0x0100000000003E00400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004100420042800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + } + } +#-} // CHECK-DAG: [[MAP_0_:#.+]] = affine_map<(d0, d1) -> (0, d1 floordiv 64, 0, d0 floordiv 32, d0 mod 32, d1 mod 64)> -// CHECK-LABEL: func.func @remove_stick_2d +// CHECK-LABEL: func @remove_stick_2d // CHECK-SAME: () -> memref<2x3xf32> { -// CHECK-DAG: [[VAR_0_:%.+]] = "zlow.stickifiedConstant"() {alignment = 4096 : i64, layout = "2D", name = "constant_stickify_0", offset = 0 : i64, shape = [1, 1, 1, 1, 32, 64], stickified = false, value = dense<{{.}}[0.000000e+00, 1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00, 5.000000e+00]{{.}}> : tensor<2x3xf32>} : () -> memref<2x3xf16, #map> +// CHECK-DAG: [[VAR_0_:%.+]] = "krnl.global"() {alignment = 4096 : i64, name = "constant_stickify_0", shape = [1, 1, 1, 1, 32, 64], value = dense_resource : tensor<4096xi8>} : () -> memref<2x3xf16, [[MAP_0_]]> // CHECK-DAG: [[VAR_c2_:%.+]] = arith.constant 2 : index // CHECK-DAG: [[VAR_c3_:%.+]] = arith.constant 3 : index // CHECK-DAG: [[RES_:%.+]] = memref.alloc() {{.*}}: memref<2x3xf32> @@ -20,3 +27,32 @@ module { // CHECK: return [[RES_]] : memref<2x3xf32> // CHECK: } +// CHECK: dialect_resources: { +// CHECK-NEXT: builtin: { +// CHECK-NEXT: zhigh: "0x0100000000003E00400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004100420042800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +// CHECK-NEXT: } +// CHECK-NEXT: } + +// ----- + +func.func @splat_stickified_constant() -> tensor<2x3xf32> { + %0 = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense<5> : tensor<4096xi8>} : () -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "2D"}>> + %1 = "zhigh.Unstick"(%0) : (tensor<2x3xf16, #zhigh.layout<{dataLayout = "2D"}>>) -> tensor<2x3xf32> + return %1 : tensor<2x3xf32> + +// CHECK-DAG: [[MAP_0_:#.+]] = affine_map<(d0, d1) -> (0, d1 floordiv 64, 0, d0 floordiv 32, d0 mod 32, d1 mod 64)> +// CHECK-LABEL: func.func @splat_stickified_constant +// CHECK-SAME: () -> memref<2x3xf32> { +// CHECK-DAG: [[VAR_0_:%.+]] = "krnl.global"() {alignment = 4096 : i64, name = "constant_stickify_1", shape = [1, 1, 1, 1, 32, 64], value = dense_resource : tensor<4096xi8>} : () -> memref<2x3xf16, #map> +// CHECK-DAG: [[CST_2_:%.+]] = arith.constant 2 : index +// CHECK-DAG: [[CST_3_:%.+]] = arith.constant 3 : index +// CHECK-DAG: [[RES_:%.+]] = memref.alloc() {{.*}}: memref<2x3xf32> +// CHECK: "zlow.unstick"([[VAR_0_]], [[RES_]]) {layout = "2D"} : (memref<2x3xf16, #map>, memref<2x3xf32>) -> () +// CHECK: return [[RES_]] : memref<2x3xf32> +// CHECK: } +// CHECK: dialect_resources: { +// CHECK: builtin: { +// CHECK: zhigh: "0x0100000005050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505" +// CHECK: } +// CHECK: } +} diff --git a/test/mlir/accelerators/nnpa/driver/ccfd.mlir b/test/mlir/accelerators/nnpa/driver/ccfd.mlir index 690becf58b..a45bb1e9d8 100644 --- a/test/mlir/accelerators/nnpa/driver/ccfd.mlir +++ b/test/mlir/accelerators/nnpa/driver/ccfd.mlir @@ -4,61 +4,60 @@ // COM: We expect that there are only one zlow.stick for the input and one zlow.unstick for the output. // COM: It is the necessary condition to get the best performance. -CHECK-LABEL: func.func @main_graph -CHECK-DAG: zlow.stickifiedConstant -CHECK-DAG: zlow.stickifiedConstant -CHECK-DAG: memref.alloc -CHECK-NEXT: zlow.stick -CHECK-DAG: zlow.stickifiedConstant - -CHECK-DAG: zlow.stickifiedConstant -CHECK-DAG: zlow.stickifiedConstant -CHECK-DAG: memref.alloc -CHECK-DAG: memref.alloc -CHECK-DAG: krnl.global -CHECK-DAG: memref.alloc -CHECK-NEXT: zlow.lstm +// CHECK-LABEL: func.func @main_graph +// CHECK-DAG: krnl.global +// CHECK-DAG: krnl.global +// CHECK-DAG: memref.alloc +// CHECK-NEXT: zlow.stick + +// CHECK-DAG: krnl.global +// CHECK-DAG: krnl.global +// CHECK-DAG: krnl.global +// CHECK-DAG: memref.alloc +// CHECK-DAG: memref.alloc +// CHECK-DAG: krnl.global +// CHECK-DAG: memref.alloc +// CHECK-NEXT: zlow.lstm // No stick and unstick between two LSTMs. -CHECK-NOT: zlow.stick -CHECK-NOT: zlow.unstick - -CHECK-DAG: zlow.stickifiedConstant -CHECK-DAG: zlow.stickifiedConstant -CHECK-DAG: zlow.stickifiedConstant -CHECK-DAG: zlow.stickifiedConstant -CHECK-DAG: memref.alloc -CHECK-DAG: memref.alloc -CHECK-DAG: krnl.global -CHECK-DAG: memref.alloc -CHECK-NEXT: zlow.lstm - +// CHECK-NOT: zlow.stick +// CHECK-NOT: zlow.unstick +// +// CHECK-DAG: krnl.global +// CHECK-DAG: krnl.global +// CHECK-DAG: krnl.global +// CHECK-DAG: memref.alloc +// CHECK-DAG: memref.alloc +// CHECK-DAG: krnl.global +// CHECK-DAG: memref.alloc +// CHECK-NEXT: zlow.lstm +// // No stick and unstick in between. -CHECK-NOT: zlow.stick -CHECK-NOT: zlow.unstick - -CHECK-DAG: zlow.stickifiedConstant -CHECK-DAG: memref.alloc -CHECK-DAG: krnl.global -CHECK-DAG: zlow.stickifiedConstant -CHECK-NEXT: zlow.matmul - +// CHECK-NOT: zlow.stick +// CHECK-NOT: zlow.unstick +// +// CHECK-DAG: krnl.global +// CHECK-DAG: memref.alloc +// CHECK-DAG: krnl.global +// CHECK-DAG: krnl.global +// CHECK-NEXT: zlow.matmul +// // No stick and unstick in between. -CHECK-NOT: zlow.stick -CHECK-NOT: zlow.unstick - -CHECK-DAG: zlow.stickifiedConstant -CHECK-DAG: memref.alloc -CHECK-DAG: krnl.global -CHECK-NEXT: zlow.add - +// CHECK-NOT: zlow.stick +// CHECK-NOT: zlow.unstick +// +// CHECK-DAG: krnl.global +// CHECK-DAG: memref.alloc +// CHECK-DAG: krnl.global +// CHECK-NEXT: zlow.add +// // No stick and unstick in between. -CHECK-NOT: zlow.stick -CHECK-NOT: zlow.unstick - -CHECK-DAG: memref.alloc -CHECK-DAG: krnl.global -CHECK-NEXT: zlow.sigmoid - -CHECK: memref.alloc -CHECK-NEXT: zlow.unstick +// CHECK-NOT: zlow.stick +// CHECK-NOT: zlow.unstick +// +// CHECK-DAG: memref.alloc +// CHECK-DAG: krnl.global +// CHECK-NEXT: zlow.sigmoid +// +// CHECK: memref.alloc +// CHECK-NEXT: zlow.unstick diff --git a/test/mlir/accelerators/nnpa/driver/dense-out-attention-layer.mlir b/test/mlir/accelerators/nnpa/driver/dense-out-attention-layer.mlir index 11ccc619a0..863efd1ee4 100644 --- a/test/mlir/accelerators/nnpa/driver/dense-out-attention-layer.mlir +++ b/test/mlir/accelerators/nnpa/driver/dense-out-attention-layer.mlir @@ -14,6 +14,6 @@ func.func @test_matmul_add_add(%arg0: tensor, %arg1: tensor<768x768 // CHECK-SAME: ([[PARAM_0_:%.+]]: tensor, [[PARAM_1_:%.+]]: tensor<768x768xf32>) -> tensor { // CHECK-DAG: [[VAR_0_:%.+]] = "zhigh.Stick"([[PARAM_0_]]) {layout = "3DS"} : (tensor) -> tensor> // CHECK-DAG: [[VAR_1_:%.+]] = "zhigh.Stick"([[PARAM_1_]]) {layout = "2D"} : (tensor<768x768xf32>) -> tensor<768x768xf16, #zhigh.layout<{dataLayout = "2D"}>> -// CHECK-DAG: [[VAR_2_:%.+]] = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<5.000000e+00> : tensor<768xf32>} : () -> tensor<768xf16, #zhigh.layout<{dataLayout = "1D"}>> +// CHECK-DAG: [[VAR_2_:%.+]] = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<49152xi8>} : () -> tensor<768xf16, #zhigh.layout<{dataLayout = "1D"}>> // CHECK: [[VAR_3_:%.+]] = "zhigh.MatMul"([[VAR_0_]], [[VAR_1_]], [[VAR_2_]]) : (tensor>, tensor<768x768xf16, #zhigh.layout<{dataLayout = "2D"}>>, tensor<768xf16, #zhigh.layout<{dataLayout = "1D"}>>) -> tensor> } diff --git a/test/mlir/accelerators/nnpa/transform/zhigh-constant-propagation-be/constprop.mlir b/test/mlir/accelerators/nnpa/transform/zhigh-constant-propagation-be/constprop.mlir index 27c53c501b..609cab1aec 100644 --- a/test/mlir/accelerators/nnpa/transform/zhigh-constant-propagation-be/constprop.mlir +++ b/test/mlir/accelerators/nnpa/transform/zhigh-constant-propagation-be/constprop.mlir @@ -9,11 +9,16 @@ func.func @remove_stick_1d() -> tensor<6xf16, #zhigh.layout<{dataLayout = "1D"}> %res = "zhigh.Stick"(%inp) {layout = "1D"} : (tensor<6xf32>) -> tensor<6xf16, #zhigh.layout<{dataLayout = "1D"}>> return %res : tensor<6xf16, #zhigh.layout<{dataLayout = "1D"}>> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<[0.000000e+00, 1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00, 5.000000e+00]> : tensor<6xf32>} : () -> tensor<6xf16, #zhigh.layout<{dataLayout = "1D"}>> + // CHECK-NEXT: %0 = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<4096xi8>} : () -> tensor<6xf16, #zhigh.layout<{dataLayout = "1D"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.Stick" + // CHECK: dialect_resources: { + // CHECK-NEXT: builtin: { + // CHECK-NEXT: zhigh: "0x0100000000003E00400041004200428000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + // CHECK-NEXT: } + // CHECK-NEXT: } } // ----- @@ -26,10 +31,16 @@ func.func @remove_stick_2d() -> tensor<2x3xf32> { %res = "zhigh.Unstick"(%st) {layout = "2D"} : (tensor<2x3xf16, #zhigh.layout<{dataLayout = "2D"}>>) -> tensor<2x3xf32> return %res : tensor<2x3xf32> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<{{.}}[0.000000e+00, 1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00, 5.000000e+00]{{.}}> : tensor<2x3xf32>} : () -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "2D"}>> + // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<4096xi8>} : () -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "2D"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.Stick" + + // CHECK: dialect_resources: { + // CHECK-NEXT: builtin: { + // CHECK-NEXT: zhigh: "0x0100000000003E00400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004100420042800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + // CHECK-NEXT: } + // CHECK-NEXT: } } // ----- @@ -41,10 +52,16 @@ func.func @remove_stick_2ds() -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "2D %res = "zhigh.Stick"(%inp) {layout = "2DS"} : (tensor<2x3xf32>) -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "2DS"}>> return %res : tensor<2x3xf16, #zhigh.layout<{dataLayout = "2DS"}>> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<{{.}}[0.000000e+00, 1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00, 5.000000e+00]{{.}}> : tensor<2x3xf32>} : () -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "2DS"}>> + // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<8192xi8>} : () -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "2DS"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.Stick" + + // CHECK: dialect_resources: { + // CHECK-NEXT: builtin: { + // CHECK-NEXT: zhigh: "0x0100000000003E0040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041004200428000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + // CHECK-NEXT: } + // CHECK-NEXT: } } // ----- @@ -56,10 +73,16 @@ func.func @remove_stick_3d() -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "3 %res = "zhigh.Stick"(%inp) {layout = "3D"} : (tensor<1x2x3xf32>) -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "3D"}>> return %res : tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "3D"}>> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<{{.}}{{.}}[0.000000e+00, 1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00, 5.000000e+00]{{.}}{{.}}> : tensor<1x2x3xf32>} : () -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "3D"}>> + // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<4096xi8>} : () -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "3D"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.Stick" + + // CHECK: dialect_resources: { + // CHECK-NEXT: builtin: { + // CHECK-NEXT: zhigh: "0x0100000000003E00400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004100420042800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + // CHECK-NEXT: } + // CHECK-NEXT: } } // ----- @@ -71,10 +94,16 @@ func.func @remove_stick_3ds() -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = " %res = "zhigh.Stick"(%inp) {layout = "3DS"} : (tensor<1x2x3xf32>) -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "3DS"}>> return %res : tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "3DS"}>> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<{{.}}{{.}}[0.000000e+00, 1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00, 5.000000e+00]{{.}}{{.}}> : tensor<1x2x3xf32>} : () -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "3DS"}>> + // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<4096xi8>} : () -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "3DS"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.Stick" + + // CHECK: dialect_resources: { + // CHECK-NEXT: builtin: { + // CHECK-NEXT: zhigh: "0x0100000000003E00400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004100420042800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + // CHECK-NEXT: } + // CHECK-NEXT: } } // ----- @@ -86,10 +115,16 @@ func.func @remove_stick_4d() -> tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = %res = "zhigh.Stick"(%inp) {layout = "4D"} : (tensor<1x1x2x3xf32>) -> tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = "4D"}>> return %res : tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = "4D"}>> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<{{.}}[{{.}}[0.000000e+00, 1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00, 5.000000e+00]{{.}}{{.}}]> : tensor<1x1x2x3xf32>} : () -> tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = "4D"}>> + // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<4096xi8>} : () -> tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = "4D"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.Stick" + + // CHECK: dialect_resources: { + // CHECK-NEXT: builtin: { + // CHECK-NEXT: zhigh: "0x0100000000003E00400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004100420042800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + // CHECK-NEXT: } + // CHECK-NEXT: } } // ----- @@ -101,10 +136,16 @@ func.func @remove_stick_nhwc() -> tensor<1x2x3x1xf16, #zhigh.layout<{dataLayout %res = "zhigh.Stick"(%inp) {layout = "NHWC"} : (tensor<1x1x2x3xf32>) -> tensor<1x2x3x1xf16, #zhigh.layout<{dataLayout = "NHWC"}>> return %res : tensor<1x2x3x1xf16, #zhigh.layout<{dataLayout = "NHWC"}>> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<{{.}}[{{.}}[0.000000e+00, 1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00, 5.000000e+00]{{.}}{{.}}]> : tensor<1x1x2x3xf32>} : () -> tensor<1x2x3x1xf16, #zhigh.layout<{dataLayout = "NHWC"}>> + // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<8192xi8>} : () -> tensor<1x2x3x1xf16, #zhigh.layout<{dataLayout = "NHWC"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.Stick" + + // CHECK: dialect_resources: { + // CHECK-NEXT: builtin: { + // CHECK-NEXT: zhigh: "0x0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000428000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + // CHECK-NEXT: } + // CHECK-NEXT: } } // ----- @@ -116,10 +157,16 @@ func.func @remove_stick_nchw() -> tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout %res = "zhigh.Stick"(%inp) {layout = "NCHW"} : (tensor<1x1x2x3xf32>) -> tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = "NCHW"}>> return %res : tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = "NCHW"}>> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<{{.}}[{{.}}[0.000000e+00, 1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00, 5.000000e+00]{{.}}{{.}}]> : tensor<1x1x2x3xf32>} : () -> tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = "NCHW"}>> + // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<8192xi8>} : () -> tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = "NCHW"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.Stick" + + // CHECK: dialect_resources: { + // CHECK-NEXT: builtin: { + // CHECK-NEXT: zhigh: "0x0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000428000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + // CHECK-NEXT: } + // CHECK-NEXT: } } // ----- @@ -131,10 +178,16 @@ func.func @remove_stick_cnnk_hwck() -> tensor<1x1x2x3xf16, #zhigh.layout<{dataLa %res = "zhigh.Stick"(%inp) {layout = "HWCK"} : (tensor<1x1x2x3xf32>) -> tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = "HWCK"}>> return %res : tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = "HWCK"}>> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<{{.}}[{{.}}[0.000000e+00, 1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00, 5.000000e+00]{{.}}{{.}}]> : tensor<1x1x2x3xf32>} : () -> tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = "HWCK"}>> + // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<4096xi8>} : () -> tensor<1x1x2x3xf16, #zhigh.layout<{dataLayout = "HWCK"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.Stick" + + // CHECK: dialect_resources: { + // CHECK-NEXT: builtin: { + // CHECK-NEXT: zhigh: "0x0100000000003E00400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004100420042800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + // CHECK-NEXT: } + // CHECK-NEXT: } } // ----- @@ -149,7 +202,7 @@ func.func @remove_stick_zrh_2d() -> tensor<2x3xf16, #zhigh.layout<{dataLayout = %res = "zhigh.StickForGRU"(%z, %r, %h) : (tensor<2x3xf32>, tensor<2x3xf32>, tensor<2x3xf32>) -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "ZRH"}>> return %res : tensor<2x3xf16, #zhigh.layout<{dataLayout = "ZRH"}>> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = true, value = dense_resource : tensor<24576xi8>} : () -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "ZRH"}>> + // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<24576xi8>} : () -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "ZRH"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.StickForGRU" @@ -173,7 +226,7 @@ func.func @remove_stick_zrh_3d() -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout %res = "zhigh.StickForGRU"(%z, %r, %h) : (tensor<1x2x3xf32>, tensor<1x2x3xf32>, tensor<1x2x3xf32>) -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "ZRH"}>> return %res : tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "ZRH"}>> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = true, value = dense_resource : tensor<12288xi8>} : () -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "ZRH"}>> + // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<12288xi8>} : () -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "ZRH"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.StickForGRU" @@ -198,7 +251,7 @@ func.func @remove_stick_fico_2d() -> tensor<2x3xf16, #zhigh.layout<{dataLayout = %res = "zhigh.StickForLSTM"(%f, %i, %c, %o) : (tensor<2x3xf32>, tensor<2x3xf32>, tensor<2x3xf32>, tensor<2x3xf32>) -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "FICO"}>> return %res : tensor<2x3xf16, #zhigh.layout<{dataLayout = "FICO"}>> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = true, value = dense_resource : tensor<32768xi8>} : () -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "FICO"}>> + // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<32768xi8>} : () -> tensor<2x3xf16, #zhigh.layout<{dataLayout = "FICO"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.StickForLSTM" @@ -223,7 +276,7 @@ func.func @remove_stick_fico_3d() -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout %res = "zhigh.StickForLSTM"(%f, %i, %c, %o) : (tensor<1x2x3xf32>, tensor<1x2x3xf32>, tensor<1x2x3xf32>, tensor<1x2x3xf32>) -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "FICO"}>> return %res : tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "FICO"}>> - // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = true, value = dense_resource : tensor<16384xi8>} : () -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "FICO"}>> + // CHECK-NEXT: "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<16384xi8>} : () -> tensor<1x2x3xf16, #zhigh.layout<{dataLayout = "FICO"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.StickForLSTM" @@ -244,10 +297,16 @@ func.func @out_of_range_minimum() -> tensor<1xf16, #zhigh.layout<{dataLayout = " %res = "zhigh.Stick"(%inp) {layout = "1D"} : (tensor<1xf32>) -> tensor<1xf16, #zhigh.layout<{dataLayout = "1D"}>> return %res : tensor<1xf16, #zhigh.layout<{dataLayout = "1D"}>> - // CHECK-NEXT: %0 = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<-3.402820e+38> : tensor<1xf32>} : () -> tensor<1xf16, #zhigh.layout<{dataLayout = "1D"}>> + // CHECK-NEXT: %0 = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<4096xi8>} : () -> tensor<1xf16, #zhigh.layout<{dataLayout = "1D"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.Stick" + + // CHECK: dialect_resources: { + // CHECK-NEXT: builtin: { + // CHECK-NEXT: zhigh: "0x01000000FFFE0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + // CHECK-NEXT: } + // CHECK-NEXT: } } // ----- @@ -258,9 +317,14 @@ func.func @out_of_range_maximum() -> tensor<1xf16, #zhigh.layout<{dataLayout = " %res = "zhigh.Stick"(%inp) {layout = "1D"} : (tensor<1xf32>) -> tensor<1xf16, #zhigh.layout<{dataLayout = "1D"}>> return %res : tensor<1xf16, #zhigh.layout<{dataLayout = "1D"}>> - // CHECK-NEXT: %0 = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, stickified = false, value = dense<3.402820e+38> : tensor<1xf32>} : () -> tensor<1xf16, #zhigh.layout<{dataLayout = "1D"}>> + // CHECK-NEXT: %0 = "zhigh.StickifiedConstant"() {alignment = 4096 : i64, value = dense_resource : tensor<4096xi8>} : () -> tensor<1xf16, #zhigh.layout<{dataLayout = "1D"}>> // CHECK-NOT: "onnx.Constant" // CHECK-NOT: "zhigh.Stick" + // CHECK: dialect_resources: { + // CHECK-NEXT: builtin: { + // CHECK-NEXT: zhigh: "0x010000007FFE0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + // CHECK-NEXT: } + // CHECK-NEXT: } }