Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Constant Propagation for ReduceLogSum Backend tests #2517

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docker/Dockerfile.onnx-mlir
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN ONNX_ROOT=${WORK_DIR}/onnx-mlir/third_party/onnx \
ARG NPROC=4
ARG ACCEL=NNPA
ARG TEST_NOFLOAT16
ARG TEST_CONSTANT_PROP
ARG TEST_MCPU
ARG KEEPSRC

Expand Down Expand Up @@ -55,6 +56,10 @@ RUN LLVM_PROJECT_ROOT=${WORK_DIR}/llvm-project \
&& TEST_MCPU=${TEST_MCPU:-$([ "$(uname -m)" = "s390x" ] && echo z14 || \
([ "$(uname -m)" = "x86_64" ] && echo || \
([ "$(uname -m)" = "ppc64le" ] && echo || echo)))} \
# Enable Constant Propagation
&& TEST_CONSTANT_PROP=${TEST_CONSTANT_PROP:-$([ "$(uname -m)" = "s390x" ] && echo true || \
([ "$(uname -m)" = "x86_64" ] && echo true || \
([ "$(uname -m)" = "ppc64le" ] && echo true || echo true)))} \
hamptonm1 marked this conversation as resolved.
Show resolved Hide resolved
&& TEST_ARGS="-mcpu=${TEST_MCPU}" \
&& make check-docs \
&& make check-unittest \
Expand All @@ -64,6 +69,7 @@ RUN LLVM_PROJECT_ROOT=${WORK_DIR}/llvm-project \
TEST_NOFLOAT16=${TEST_NOFLOAT16} \
TEST_MCPU=${TEST_MCPU} \
TEST_ARGS="${TEST_ARGS}" \
TEST_CONSTANT_PROP=${TEST_CONSTANT_PROP} \
-j${NPROC} \
check-onnx-backend-numerical \
&& make -j${NPROC} install \
Expand Down
6 changes: 6 additions & 0 deletions docker/Dockerfile.onnx-mlir-dev
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ARG NPROC=4
ARG ACCEL=NNPA
ARG TEST_NOFLOAT16
ARG TEST_MCPU
ARG TEST_CONSTANT_PROP

RUN LLVM_PROJECT_ROOT=${WORK_DIR}/llvm-project \
&& ONNX_MLIR_ROOT=${WORK_DIR}/onnx-mlir \
Expand Down Expand Up @@ -54,6 +55,10 @@ RUN LLVM_PROJECT_ROOT=${WORK_DIR}/llvm-project \
&& TEST_MCPU=$([ "$(uname -m)" = "s390x" ] && echo || \
([ "$(uname -m)" = "x86_64" ] && echo || \
([ "$(uname -m)" = "ppc64le" ] && echo || echo))) \
# Enable Constant Propagation
&& TEST_CONSTANT_PROP=${TEST_CONSTANT_PROP:-$([ "$(uname -m)" = "s390x" ] && echo true || \
([ "$(uname -m)" = "x86_64" ] && echo true || \
([ "$(uname -m)" = "ppc64le" ] && echo true || echo true)))} \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha... makes sense

&& TEST_ARGS="-mcpu=${TEST_MCPU}" \
&& TEST_OPTLEVEL=0 \
&& make check-docs \
Expand All @@ -65,6 +70,7 @@ RUN LLVM_PROJECT_ROOT=${WORK_DIR}/llvm-project \
TEST_MCPU=${TEST_MCPU} \
TEST_ARGS="${TEST_ARGS}" \
TEST_OPTLEVEL=${TEST_OPTLEVEL} \
TEST_CONSTANT_PROP=${TEST_CONSTANT_PROP} \
-j${NPROC} \
check-onnx-backend-numerical \
&& rm -f Debug/bin/*Test Debug/bin/Perf* Debug/bin/Test* \
Expand Down
4 changes: 3 additions & 1 deletion test/backend/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

##################### common.py ################################################
#
# Copyright 2021-2022 The IBM Research Authors.
# Copyright 2021-2023 The IBM Research Authors.
#
################################################################################
# commom function `compile_model` called by both
Expand Down Expand Up @@ -125,6 +125,8 @@ def compile_model(model, emit):
if args.constants_to_file_total_threshold:
command_list.append("--constants-to-file-total-threshold=" +
str(args.constants_to_file_total_threshold))
if args.enable_constant_prop:
command_list.append("--enable-constant-prop=true")

command_list.append(target[emit])
command_list.append(model_name)
Expand Down
6 changes: 3 additions & 3 deletions test/backend/inference_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,13 +771,13 @@ def get_test_models():

# ==OP== ReduceLogSum
# ==MIN== 13
# ==LIM== do_not_keep_dim not supported.
# ==LIM== do_not_keep_dim not supported. Enable constant propagation
#"test_reduce_log_sum_desc_axes_cpu": {STATIC_SHAPE:{}, DYNAMIC_SHAPE:{-1:{-1}}, CONSTANT_INPUT:{-1}},
#"test_reduce_log_sum_asc_axes_cpu": {STATIC_SHAPE:{}, DYNAMIC_SHAPE:{-1:{-1}}, CONSTANT_INPUT:{-1}},
#"test_reduce_log_sum_default_cpu": {STATIC_SHAPE:{}, DYNAMIC_SHAPE:{-1:{-1}}, CONSTANT_INPUT:{-1}},
"test_reduce_log_sum_default_cpu": {STATIC_SHAPE:{}, DYNAMIC_SHAPE:{-1:{-1}}, CONSTANT_INPUT:{-1}, ENABLE_CONST_PROP:{}},
"test_reduce_log_sum_negative_axes_cpu": {STATIC_SHAPE:{}, DYNAMIC_SHAPE:{-1:{-1}}, CONSTANT_INPUT:{-1}},
# Name changed in v13
# "test_reduce_log_sum_default_expanded_cpu": {STATIC_SHAPE:{}, DYNAMIC_SHAPE:{-1:{-1}}, CONSTANT_INPUT:{-1}},
"test_reduce_log_sum_default_expanded_cpu": {STATIC_SHAPE:{}, DYNAMIC_SHAPE:{-1:{-1}}, CONSTANT_INPUT:{-1}, ENABLE_CONST_PROP:{}},

# ==OP== ReduceL1
# ==MIN== 13
Expand Down
11 changes: 10 additions & 1 deletion test/backend/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

############################ variables.py #####################################
#
# Copyright 2021-2022 The IBM Research Authors.
# Copyright 2021-2023 The IBM Research Authors.
#
################################################################################
# Immutable global variables:
Expand Down Expand Up @@ -55,6 +55,7 @@ def get_args_from_env():
TEST_INSTRUCTION_CHECK = os.getenv("TEST_INSTRUCTION_CHECK")
TEST_CONSTANTS_TO_FILE = os.getenv("TEST_CONSTANTS_TO_FILE")
TEST_NOFLOAT16 = os.getenv("TEST_NOFLOAT16")
TEST_CONSTANT_PROP= os.getenv("TEST_CONSTANT_PROP")

# Set ONNX_HOME to /tmp if not set to prevent onnx from downloading
# real model files into home directory.
Expand Down Expand Up @@ -86,6 +87,13 @@ def get_args_from_env():
default=(strtobool(TEST_CONSTANTS_TO_FILE) if TEST_CONSTANTS_TO_FILE else False),
help="whether store constants to file or not, passed to the compiler",
)
parser.add_argument(
"--enable_constant_prop",
action="store_true",
default=(strtobool(TEST_CONSTANT_PROP) if TEST_CONSTANT_PROP else False),
help="enable constant propagation",
)

parser.add_argument(
"--nofloat16",
action="store_true",
Expand Down Expand Up @@ -270,6 +278,7 @@ def get_runtime_vars():
CONSTANT_INPUT = "constant"
CONSTANTS_TO_FILE = "constants_to_file"
FLOAT16 = "float16"
ENABLE_CONST_PROP = "enable_constant_prop"

### immutable variables ###

Expand Down