Skip to content

Commit 86b8f18

Browse files
Since compiler generated stick/unstick is default on, change new option to disable it (#3073)
Signed-off-by: Alexandre Eichenberger <[email protected]>
1 parent 2bede1a commit 86b8f18

File tree

12 files changed

+22
-22
lines changed

12 files changed

+22
-22
lines changed

src/Accelerators/NNPA/Compiler/NNPACompilerOptions.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ llvm::cl::opt<bool> nnpaEnableZHighDecomposeStickUnstick(
4949

5050
// Enabled default now, could also enable it only if parallel is on as parallel
5151
// stick/unstick is quite a bit faster than sequential.
52-
llvm::cl::opt<bool> nnpaEnableCompilerStickUnstick(
53-
"enable-compiler-stick-unstick",
54-
llvm::cl::desc("[Experimental feature] Enable the compiler generate some "
55-
"stick/unstick code. Default is true."),
56-
llvm::cl::init(true), llvm::cl::cat(OnnxMlirCommonOptions));
52+
llvm::cl::opt<bool> nnpaDisableCompilerStickUnstick(
53+
"disable-compiler-stick-unstick",
54+
llvm::cl::desc("Disable the compiler to generate some "
55+
"stick/unstick code. Default is false."),
56+
llvm::cl::init(false), llvm::cl::cat(OnnxMlirCommonOptions));
5757

5858
llvm::cl::opt<bool> nnpaEnableScalarBcastBinary(
5959
"nnpa-enable-scalar-bcast-binary",
@@ -94,7 +94,7 @@ llvm::cl::opt<NNPAPlacementHeuristic> nnpaPlacementHeuristic{
9494

9595
llvm::cl::opt<bool> nnpaEnableSaturation("nnpa-saturation",
9696
llvm::cl::desc("Enable saturating f32 values before stickify them."
97-
"This option turns enable-compiler-stick-unstick on."
97+
"This option turns off disable-compiler-stick-unstick."
9898
"Default is false."),
9999
llvm::cl::init(false), llvm::cl::cat(OnnxMlirCommonOptions));
100100

src/Accelerators/NNPA/Compiler/NNPACompilerOptions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ extern llvm::cl::OptionCategory OnnxMlirCommonOptions;
6969
extern llvm::cl::opt<onnx_mlir::NNPAEmissionTargetType> nnpaEmissionTarget;
7070
extern llvm::cl::opt<bool> nnpaDisableZHighToOnnx;
7171
extern llvm::cl::opt<bool> nnpaEnableZHighDecomposeStickUnstick;
72-
extern llvm::cl::opt<bool> nnpaEnableCompilerStickUnstick;
72+
extern llvm::cl::opt<bool> nnpaDisableCompilerStickUnstick;
7373
extern llvm::cl::opt<bool> nnpaEnableScalarBcastBinary;
7474
extern llvm::cl::opt<NNPAPlacementHeuristic> nnpaPlacementHeuristic;
7575
extern llvm::cl::opt<bool> profileZHighIR;

src/Accelerators/NNPA/Compiler/NNPACompilerUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void configurePassesNNPA() {
5252
// z16 does not support for hardware saturation.
5353
// So, force its usage to compiler generated sticks.
5454
if (nnpaEnableSaturation && isLessEqualNNPALevel(NNPALevel::M14))
55-
nnpaEnableCompilerStickUnstick = true;
55+
nnpaDisableCompilerStickUnstick = false;
5656

5757
// Configure ONNXToZHighLoweringPass.
5858
bool isDynQuant = !nnpaQuantDynamic.empty();
@@ -272,7 +272,7 @@ void addPassesNNPA(mlir::OwningOpRef<mlir::ModuleOp> &module,
272272
pm.addPass(zlow::createZLowRewritePass());
273273
// Late generation of code for stick/unstick, needed to be after a
274274
// ZLowRewrite pass.
275-
if (nnpaEnableCompilerStickUnstick)
275+
if (!nnpaDisableCompilerStickUnstick)
276276
pm.addPass(zlow::createZLowStickExpansionPass(enableParallel));
277277
pm.addPass(mlir::createCanonicalizerPass());
278278
// Normalize MemRefs.
@@ -284,7 +284,7 @@ void addPassesNNPA(mlir::OwningOpRef<mlir::ModuleOp> &module,
284284
pm.addPass(zlow::createZLowRewritePass());
285285
// The createZLowStickExpansion pass may create parallel constructs,
286286
// they need to be handled here.
287-
if (nnpaEnableCompilerStickUnstick && enableParallel)
287+
if (!nnpaDisableCompilerStickUnstick && enableParallel)
288288
pm.addPass(mlir::createConvertSCFToOpenMPPass());
289289

290290
pm.addPass(mlir::createCanonicalizerPass());

src/Accelerators/NNPA/Conversion/ZHighToZLow/ZHighToZLow.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ struct ZHighToZLowStickOpLowering : public ConversionPattern {
561561
Value alloc = insertAllocForZMemRef(
562562
zMemRefType, shapeHelper.getOutputDims(), op, rewriter);
563563
if (isNHWCLayout(layout)) {
564-
if (nnpaEnableCompilerStickUnstick) {
564+
if (!nnpaDisableCompilerStickUnstick) {
565565
// Compiler-generated stick hasn't supported NCHW yet.
566566
// Explicitly transpose NCHW to NHWC.
567567
input = create.onnx.toMemref(
@@ -818,7 +818,7 @@ struct ZHighToZLowUnstickOpLowering : public ConversionPattern {
818818
// Allocate a buffer for the result MemRef.
819819
Value alloc = nullptr;
820820
if (isNHWCLayout(layout)) {
821-
if (nnpaEnableCompilerStickUnstick) {
821+
if (!nnpaDisableCompilerStickUnstick) {
822822
// Compiler-generated unstick hasn't supported NCHW yet.
823823
// This code allocates a NHWC buffer. It gets dims from the NCHW input.
824824
SmallVector<IndexExpr> dimList;
@@ -845,7 +845,7 @@ struct ZHighToZLowUnstickOpLowering : public ConversionPattern {
845845

846846
// Emit a ZLow operation.
847847
rewriter.create<ZLowUnstickOp>(loc, input, alloc, layout);
848-
if (isNHWCLayout(layout) && nnpaEnableCompilerStickUnstick)
848+
if (isNHWCLayout(layout) && !nnpaDisableCompilerStickUnstick)
849849
// Compiler-generated unstick hasn't supported NCHW yet.
850850
// Explicitly transpose NHWC to NCHW.
851851
alloc =

test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/compiler-stick-unstick.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: onnx-mlir-opt --march=z16 --maccel=NNPA --enable-compiler-stick-unstick=true --shape-inference --convert-onnx-to-krnl --canonicalize %s -split-input-file | FileCheck %s
1+
// RUN: onnx-mlir-opt --march=z16 --maccel=NNPA --shape-inference --convert-onnx-to-krnl --canonicalize %s -split-input-file | FileCheck %s
22

33
func.func @should_lower_to_zlow(%arg0: tensor<1x3x5x7xf32>) -> tensor<*xf32> {
44
%0 = "zhigh.Stick"(%arg0) {layout = "NHWC"} : (tensor<1x3x5x7xf32>) -> tensor<*xf16>

test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/stick-unstick.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: onnx-mlir-opt --march=z16 --maccel=NNPA --enable-compiler-stick-unstick=false --shape-inference --convert-onnx-to-krnl --canonicalize %s -split-input-file | FileCheck %s
1+
// RUN: onnx-mlir-opt --march=z16 --maccel=NNPA --disable-compiler-stick-unstick --shape-inference --convert-onnx-to-krnl --canonicalize %s -split-input-file | FileCheck %s
22

33
func.func @should_lower_to_zlow(%arg0: tensor<1x3x5x7xf32>) -> tensor<*xf32> {
44
%0 = "zhigh.Stick"(%arg0) {layout = "NHWC"} : (tensor<1x3x5x7xf32>) -> tensor<*xf16>

test/mlir/accelerators/nnpa/conversion/zhigh-to-zlow/test-datalayout.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: onnx-mlir-opt --march=z16 --maccel=NNPA --enable-compiler-stick-unstick=false --shape-inference --convert-onnx-to-krnl --canonicalize %s -split-input-file | FileCheck %s
1+
// RUN: onnx-mlir-opt --march=z16 --maccel=NNPA --disable-compiler-stick-unstick --shape-inference --convert-onnx-to-krnl --canonicalize %s -split-input-file | FileCheck %s
22

33
func.func @should_lower_to_zlow_1d(%arg0: tensor<7xf32>) -> tensor<*xf16> {
44
%0 = "zhigh.Stick"(%arg0) {layout = "1D"} : (tensor<7xf32>) -> tensor<*xf16>

test/mlir/accelerators/nnpa/driver/ccfd.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: ccfd=$(dirname %s)/ccfd.onnx && curl -L https://github.com/IBM/ai-on-z-fraud-detection/raw/main/onnx%20models/ccf_lstm_static_tf2onnx_OS_new.onnx -o ${ccfd} && onnx-mlir --march=z16 --maccel=NNPA --enable-compiler-stick-unstick=false --EmitMLIR --printIR -tag="test" ${ccfd} | FileCheck %s && rm -rf ${ccfd}
1+
// RUN: ccfd=$(dirname %s)/ccfd.onnx && curl -L https://github.com/IBM/ai-on-z-fraud-detection/raw/main/onnx%20models/ccf_lstm_static_tf2onnx_OS_new.onnx -o ${ccfd} && onnx-mlir --march=z16 --maccel=NNPA --disable-compiler-stick-unstick --EmitMLIR --printIR -tag="test" ${ccfd} | FileCheck %s && rm -rf ${ccfd}
22

33
// COM: This test is to check regression on the IBM CCFD model.
44
// COM: We expect that there are only one zlow.stick for the input and one zlow.unstick for the output.

test/mlir/accelerators/nnpa/driver/data-transformation-on-ztensor-num2.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: onnx-mlir --march=z16 --maccel=NNPA --enable-compiler-stick-unstick=false --EmitMLIR --printIR -tag="test" %s | FileCheck %s
1+
// RUN: onnx-mlir --march=z16 --maccel=NNPA --disable-compiler-stick-unstick --EmitMLIR --printIR -tag="test" %s | FileCheck %s
22

33
// -----
44

test/mlir/accelerators/nnpa/driver/data-transformation-on-ztensor.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: onnx-mlir --march=z16 --maccel=NNPA --enable-compiler-stick-unstick=false --EmitMLIR --printIR -tag="test" %s | FileCheck %s
1+
// RUN: onnx-mlir --march=z16 --maccel=NNPA --disable-compiler-stick-unstick --EmitMLIR --printIR -tag="test" %s | FileCheck %s
22

33
// -----
44

0 commit comments

Comments
 (0)