forked from onnx/onnx-mlir
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.onnx-mlir-dev
102 lines (92 loc) · 3.83 KB
/
Dockerfile.onnx-mlir-dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
ARG BASE_IMAGE
FROM ${BASE_IMAGE} AS onnx-mlir-dev-test
# Label the base image so it can be cleaned up after becoming dangling
ARG ONNX_MLIR_PR_NUMBER
ARG ONNX_MLIR_PR_NUMBER2
LABEL onnx_mlir_pr_number=${ONNX_MLIR_PR_NUMBER}
LABEL onnx_mlir_pr_number2=${ONNX_MLIR_PR_NUMBER2}
ARG WORK_DIR=/workdir
WORKDIR ${WORK_DIR}
# Copy onnx-mlir from the pull request
COPY . onnx-mlir
# Setup onnx
RUN ONNX_ROOT=${WORK_DIR}/onnx-mlir/third_party/onnx \
&& cd ${ONNX_ROOT} && python3 -m pip install .
ARG NPROC=4
ARG ACCEL=NNPA
ARG TEST_NOFLOAT16
ARG TEST_MCPU
RUN LLVM_PROJECT_ROOT=${WORK_DIR}/llvm-project \
&& ONNX_MLIR_ROOT=${WORK_DIR}/onnx-mlir \
# Build onnx-mlir and run tests
&& cd ${ONNX_MLIR_ROOT} \
&& rm -rf build && mkdir -p build && cd build \
# NNPA acclerator is built on all archs to enable lit tests
# (dependent libzdnn is built on s390x only)
&& CC=clang CXX=clang++ \
cmake -DMLIR_DIR=${LLVM_PROJECT_ROOT}/build/lib/cmake/mlir \
-DCMAKE_BUILD_TYPE=Debug \
-DONNX_MLIR_TEST_OPTLEVEL=0 \
-DONNX_MLIR_ACCELERATORS=${ACCEL} .. \
# Run the cppcheck scanner on s390x
# onnx-{data|ml|operator-ml}.pb.cc are not generated by cmake so
# run make onnx_proto to generate them. It wasn't a problem with
# cppcheck v1.90 in Ubuntu focal since it apparently silently
# ignores nonexisting files. But cppcheck v2.7 in Ubuntu jammy
# will report error on nonexisting files.
&& if [ "$(uname -m)" = "s390x" ]; then \
make onnx_proto && NPROC=${NPROC} \
${ONNX_MLIR_ROOT}/utils/cppcheck_scan/cppcheck-scan.py; \
fi \
&& make -j${NPROC} \
&& make -j${NPROC} LIT_OPTS=-v check-onnx-lit \
# FLOAT16 backend tests only work on ppc64le platform at the moment
&& TEST_NOFLOAT16=${TEST_NOFLOAT16:-$([ "$(uname -m)" = "s390x" ] && echo true || \
([ "$(uname -m)" = "x86_64" ] && echo true || \
([ "$(uname -m)" = "ppc64le" ] && echo || echo)))} \
# Dev image is built without SIMD, placeholder for easy SIMD enablement
&& TEST_MCPU=$([ "$(uname -m)" = "s390x" ] && echo || \
([ "$(uname -m)" = "x86_64" ] && echo || \
([ "$(uname -m)" = "ppc64le" ] && echo || echo))) \
&& TEST_ARGS="-mcpu=${TEST_MCPU}" \
&& TEST_OPTLEVEL=0 \
&& make check-docs \
&& make check-unittest \
&& make check-multiple-models \
&& make NPROC=${NPROC} \
CTEST_PARALLEL_LEVEL=${NPROC} \
TEST_NOFLOAT16=${TEST_NOFLOAT16} \
TEST_MCPU=${TEST_MCPU} \
TEST_ARGS="${TEST_ARGS}" \
TEST_OPTLEVEL=${TEST_OPTLEVEL} \
-j${NPROC} \
check-onnx-backend-numerical \
&& rm -f Debug/bin/*Test Debug/bin/Perf* Debug/bin/Test* \
# When building for push event to publish the image, unshallow and
# rename origin to upstream to make the repo a bit more dev friendly.
&& if [ "${ONNX_MLIR_PR_NUMBER}" != "${ONNX_MLIR_PR_NUMBER2}" ]; then \
git fetch --unshallow && \
git remote rename origin upstream; \
fi \
# Install joblib for model zoo tests
&& pip3 install -q joblib \
&& rm -rf /tmp/*
# Copy from onnx-mlir-dev-test to squash removed source layer and
# remove dependency on base image (onnx-mlir-llvm-static)
FROM scratch
ARG WORK_DIR=/workdir
WORKDIR ${WORK_DIR}
# Label the images for various checking and cleanup
ARG ONNX_MLIR_SHA1
ARG ONNX_MLIR_SHA1_DATE
ARG ONNX_MLIR_DOCKERFILE_SHA1
ARG ONNX_MLIR_PR_NUMBER
ARG ONNX_MLIR_PR_NUMBER2
LABEL onnx_mlir_sha1=${ONNX_MLIR_SHA1}
LABEL onnx_mlir_sha1_date=${ONNX_MLIR_SHA1_DATE}
LABEL onnx_mlir_dockerfile_sha1=${ONNX_MLIR_DOCKERFILE_SHA1}
LABEL onnx_mlir_pr_number=${ONNX_MLIR_PR_NUMBER}
LABEL onnx_mlir_pr_number2=${ONNX_MLIR_PR_NUMBER2}
COPY --from=onnx-mlir-dev-test / /
CMD [ "/bin/bash" ]
LABEL onnx_mlir_successfully_built=yes