forked from mlcommons/mobile_app_open
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
159 lines (134 loc) · 5.69 KB
/
Makefile
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Copyright 2020-2021 The MLPerf Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################
.PHONY: docker_image app bazel-version rundocker clean
all: app
include tools/formatter/format.mk
# TFLite is the default backend
include mobile_back_tflite/tflite_backend.mk
ifeq (${WITH_QTI},1)
$(info WITH_QTI=1)
include mobile_back_qti/make/qti_backend.mk
include mobile_back_qti/make/qti_backend_targets.mk
endif
ifeq (${WITH_SAMSUNG},1)
$(info WITH_SAMSUNG=1)
SAMSUNG_BACKEND=--//android/java/org/mlperf/inference:with_samsung="1"
endif
ifeq (${WITH_PIXEL},1)
$(info WITH_PIXEL=1)
include mobile_back_pixel/pixel_backend.mk
endif
output/mlperf_mobile_docker_1_0.stamp: android/docker/mlperf_mobile/Dockerfile
mkdir -p output/docker
docker image build -t mlcommons/mlperf_mobile:1.0 android/docker/mlperf_mobile
touch $@
docker_image: output/mlperf_mobile_docker_1_0.stamp
COMMON_DOCKER_FLAGS1= \
-e USER=mlperf \
${PROXY_WORKAROUND1} \
-v $(CURDIR):/home/mlperf/mobile_app \
-v $(CURDIR)/output/home/mlperf/cache:/home/mlperf/cache \
${QTI_VOLUMES} \
-w /home/mlperf/mobile_app \
-u `id -u`:`id -g` \
mlcommons/mlperf_mobile:1.0 bazel-3.7.2
COMMON_DOCKER_FLAGS2= \
${PROXY_WORKAROUND2} \
--output_user_root=/home/mlperf/cache/bazel build --verbose_failures \
-c opt --cxxopt='--std=c++14' --host_cxxopt='--std=c++14' \
--host_cxxopt='-Wno-deprecated-declarations' --host_cxxopt='-Wno-class-memaccess' \
--cxxopt='-Wno-deprecated-declarations' --cxxopt='-Wno-unknown-attributes'
COMMON_DOCKER_FLAGS= \
${COMMON_DOCKER_FLAGS1} \
${COMMON_DOCKER_FLAGS2}
NATIVE_DOCKER_FLAGS= \
${COMMON_DOCKER_FLAGS1} --bazelrc=/dev/null \
${COMMON_DOCKER_FLAGS2}
proto_test: output/mlperf_mobile_docker_1_0.stamp
# Building proto_test
mkdir -p output/home/mlperf/cache && chmod 777 output/home/mlperf/cache
docker run \
${NATIVE_DOCKER_FLAGS} --experimental_repo_remote_exec \
//android/cpp/proto:proto_test
cp output/`readlink bazel-bin`/android/cpp/proto/proto_test output/proto_test
chmod 777 output/proto_test
main: output/mlperf_mobile_docker_1_0.stamp ${QTI_DEPS}
# Building main
mkdir -p output/home/mlperf/cache && chmod 777 output/home/mlperf/cache
docker run \
${COMMON_DOCKER_FLAGS} \
--config android_arm64 //mobile_back_tflite:tflitebackend ${QTI_TARGET} //android/cpp/binary:main
rm -rf output/binary && mkdir -p output/binary
cp output/`readlink bazel-bin`/android/cpp/binary/main output/binary/main
cp output/`readlink bazel-bin`/mobile_back_tflite/cpp/backend_tflite/libtflitebackend.so output/binary/libtflitebackend.so
${QTI_LIB_COPY}
chmod 777 output/binary/main output/binary/libtflitebackend.so
libtflite: output/mlperf_mobile_docker_1_0.stamp
# Building libtflite
mkdir -p output/home/mlperf/cache && chmod 777 output/home/mlperf/cache
docker run \
${COMMON_DOCKER_FLAGS} \
--config android_arm64 //mobile_back_tflite:tflitebackend
rm -rf output/binary && mkdir -p output/binary
cp output/`readlink bazel-bin`/mobile_back_tflite/cpp/backend_tflite/libtflitebackend.so output/binary/libtflitebackend.so
chmod 777 output/binary/libtflitebackend.so
app: output/mlperf_mobile_docker_1_0.stamp ${QTI_DEPS}
# Building mlperf_app.apk
mkdir -p output/home/mlperf/cache && chmod 777 output/home/mlperf/cache
docker run \
${COMMON_DOCKER_FLAGS} \
${QTI_BACKEND} ${SAMSUNG_BACKEND} ${MEDIATEK_BACKEND} ${PIXEL_BACKEND} \
--fat_apk_cpu=arm64-v8a \
//android/java/org/mlperf/inference:mlperf_app
cp output/`readlink bazel-bin`/android/java/org/mlperf/inference/mlperf_app.apk output/mlperf_app.apk
chmod 777 output/mlperf_app.apk
app_x86_64: output/mlperf_mobile_docker_1_0.stamp
# Building mlperf_app_x86_64.apk
mkdir -p output/home/mlperf/cache && chmod 777 output/home/mlperf/cache
docker run \
${COMMON_DOCKER_FLAGS} \
${QTI_BACKEND} ${SAMSUNG_BACKEND} ${MEDIATEK_BACKEND} ${PIXEL_BACKEND} \
--fat_apk_cpu=x86_64 \
//android/java/org/mlperf/inference:mlperf_app
cp output/`readlink bazel-bin`/android/java/org/mlperf/inference/mlperf_app.apk output/mlperf_app_x86_64.apk
chmod 777 output/mlperf_app.apk
test_app: output/mlperf_mobile_docker_1_0.stamp
# Building mlperf_test_app.apk
mkdir -p output/home/mlperf/cache && chmod 777 output/home/mlperf/cache
docker run \
${COMMON_DOCKER_FLAGS} \
${QTI_BACKEND} ${SAMSUNG_BACKEND} ${MEDIATEK_BACKEND} ${PIXEL_BACKEND} \
--fat_apk_cpu=x86_64,arm64-v8a \
//androidTest:mlperf_test_app
cp output/`readlink bazel-bin`/android/androidTest/mlperf_test_app.apk output/mlperf_test_app.apk
chmod 777 output/mlperf_test_app.apk
rundocker: output/mlperf_mobile_docker_1_0.stamp
docker run -it \
-e USER=mlperf \
-v $(CURDIR):/home/mlperf/mobile_app \
-v $(CURDIR)/output/home/mlperf/cache:/home/mlperf/cache \
-w /home/mlperf/mobile_app \
-u `id -u`:`id -g` \
mlcommons/mlperf_mobile:1.0
rundocker_root: output/mlperf_mobile_docker_1_0.stamp
docker run -it \
-e USER=mlperf \
-v $(CURDIR):/home/mlperf/mobile_app \
-v $(CURDIR)/output/home/mlperf/cache:/home/mlperf/cache \
-w /home/mlperf/mobile_app \
mlcommons/mlperf_mobile:1.0
clean:
([ -d output/home/mlperf/cache ] && chmod -R +w output/home/mlperf/cache) || true
rm -rf output