forked from mlcommons/mobile_app_open
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Pixel backend * add license header to resize_argmax_op*
- Loading branch information
Showing
18 changed files
with
1,480 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package( | ||
default_visibility = ["//visibility:public"], | ||
licenses = ["notice"], # Apache 2.0 | ||
) | ||
|
||
cc_library( | ||
name = "tflitepixelbackend", | ||
srcs = ["//mobile_back_pixel/cpp/backend_tflite:libtflitepixelbackend.so"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# 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. | ||
########################################################################## | ||
|
||
this_mkfile := $(abspath $(lastword $(MAKEFILE_LIST))) | ||
TOPDIR := $(shell dirname ${this_mkfile}) | ||
BUILDDIR=${TOPDIR}/build | ||
|
||
USERID=$(shell id -u) | ||
GROUPID=$(shell id -g) | ||
|
||
SRCFILES=\ | ||
Makefile \ | ||
cpp/BUILD \ | ||
cpp/c/BUILD \ | ||
cpp/c/version_script.lds \ | ||
cpp/c/backend_c.h \ | ||
cpp/c/type.h \ | ||
cpp/backend_tflite/tflite_c.cc \ | ||
cpp/backend_tflite/tflite_settings.h \ | ||
cpp/backend_tflite/utils.h \ | ||
cpp/backend_tflite/BUILD | ||
|
||
ifeq (${USE_PROXY_WORKAROUND},1) | ||
export PROXY_WORKAROUND1=\ | ||
-v /etc/ssl/certs:/etc/ssl/certs \ | ||
-v /usr/share/ca-certificates:/usr/share/ca-certificates \ | ||
-v /usr/share/ca-certificates-java:/usr/share/ca-certificates-java | ||
|
||
export PROXY_WORKAROUND2=--host_jvm_args -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts | ||
else | ||
export PROXY_WORKAROUND1= | ||
export PROXY_WORKAROUND2= | ||
endif | ||
|
||
all: ${BUILDDIR}/lib_x86_64/libtflitebackend.so ${BUILDDIR}/lib_arm64/libtflitebackend.so | ||
|
||
.PHONY: clean docker_image | ||
|
||
USER_ID=$(shell id -u) | ||
|
||
${BUILDDIR}/mlperf_mobile_image.stamp: ${TOPDIR}/docker/mlperf_mobile/Dockerfile | ||
@mkdir -p ${BUILDDIR} | ||
@docker image build -t mlcommons/mlperf_mobile:1.0 docker/mlperf_mobile | ||
@touch $@ | ||
|
||
docker_image: ${BUILDDIR}/mlperf_mobile_image.stamp | ||
|
||
${BUILDDIR}/lib_arm64/libtflitebackend.so: ${SRCFILES} docker_image | ||
@echo "Building arm64 libtflitebackend.so" | ||
@mkdir -p ${BUILDDIR}/lib_arm64 | ||
@mkdir -p ${BUILDDIR}/cache | ||
@docker run \ | ||
-e USER=mlperf \ | ||
${PROXY_WORKAROUND1} \ | ||
-v $(CURDIR):/tflite_backend \ | ||
-v ${BUILDDIR}/cache:/cache \ | ||
-w /tflite_backend \ | ||
-u ${USERID}:${GROUPID} \ | ||
mlcommons/mlperf_mobile:1.0 bazel-3.7.2 ${PROXY_WORKAROUND2} \ | ||
--output_user_root=/cache/bazel build \ | ||
-c opt --cxxopt='--std=c++14' \ | ||
--cxxopt='-Wno-deprecated-declarations' \ | ||
--cxxopt='-Wno-unknown-attributes' \ | ||
--host_cxxopt='--std=c++14' \ | ||
--host_cxxopt='-Wno-deprecated-declarations' \ | ||
--host_cxxopt='-Wno-class-memaccess' \ | ||
--config=android_arm64 \ | ||
:tflitebackend | ||
@cp build/`readlink bazel-out`/arm64-v8a-opt/bin/cpp/backend_tflite/libtflitebackend.so $@ | ||
@chmod 777 $@ | ||
|
||
${BUILDDIR}/lib_x86_64/libtflitebackend.so: ${SRCFILES} docker_image | ||
@echo "Building x86_64 libtflitebackend.so" | ||
@mkdir -p ${BUILDDIR}/lib_x86_64 | ||
@mkdir -p ${BUILDDIR}/cache | ||
docker run \ | ||
-e USER=mlperf \ | ||
${PROXY_WORKAROUND1} \ | ||
-v $(CURDIR):/tflite_backend \ | ||
-v ${BUILDDIR}/cache:/cache \ | ||
-w /tflite_backend \ | ||
-u ${USERID}:${GROUPID} \ | ||
mlcommons/mlperf_mobile:1.0 bazel-3.7.2 ${PROXY_WORKAROUND2} \ | ||
--output_user_root=/cache/bazel build \ | ||
-c opt --cxxopt='--std=c++14' \ | ||
--cxxopt='-Wno-deprecated-declarations' \ | ||
--cxxopt='-Wno-unknown-attributes' \ | ||
--host_cxxopt='--std=c++14' \ | ||
--host_cxxopt='-Wno-deprecated-declarations' \ | ||
--host_cxxopt='-Wno-class-memaccess' \ | ||
--config=android_x86_64 \ | ||
:tflitebackend | ||
@cp build/`readlink bazel-out`/x86_64-opt/bin/cpp/backend_tflite/libtflitebackend.so $@ | ||
@chmod 777 $@ | ||
|
||
clean: | ||
@rm -rf bazel-bin bazel-testlogs bazel-out bazel-tflite_backend | ||
@rm -rf ${BUILDDIR} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Mobile backend tflite | ||
|
||
Build so-library for selected architecture: | ||
```bash | ||
bazel build -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' \ | ||
--fat_apk_cpu={x86_64|arm64-v8a|armeabi-v7a} \ | ||
//cpp/backend_tflite:libtflitebackend.so | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2019 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. | ||
# ============================================================================== | ||
package( | ||
default_visibility = ["//visibility:public"], | ||
licenses = ["notice"], # Apache 2.0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Copyright 2019-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. | ||
# ============================================================================== | ||
load( | ||
"@org_tensorflow//tensorflow/lite:build_def.bzl", | ||
"tflite_copts", | ||
"tflite_jni_binary", | ||
) | ||
|
||
package( | ||
default_visibility = ["//visibility:public"], | ||
licenses = ["notice"], # Apache 2.0 | ||
) | ||
|
||
cc_library( | ||
name = "resize_bilinear_op", | ||
srcs = [ | ||
"resize_argmax_op.cc", | ||
], | ||
hdrs = [ | ||
"resize_argmax_op.h", | ||
], | ||
deps = [ | ||
"@org_tensorflow//tensorflow/lite/c:common", | ||
"@org_tensorflow//tensorflow/lite/kernels:kernel_util", | ||
"@org_tensorflow//tensorflow/lite/core/api", | ||
"@org_tensorflow//tensorflow/lite/kernels:cpu_backend_context", | ||
"@org_tensorflow//tensorflow/lite/kernels:cpu_backend_threadpool", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "tflite_pixel", | ||
srcs = [ | ||
"tflite_pixel.cc", | ||
], | ||
hdrs = [ | ||
"tflite_settings_pixel.h", | ||
"thread_pool.h", | ||
], | ||
copts = tflite_copts() + select({ | ||
"//android/commonlibs:use_asan": [ | ||
"-fsanitize=address", | ||
"-g", | ||
"-O1", | ||
"-fno-omit-frame-pointer", | ||
], | ||
"//conditions:default": [], | ||
}), | ||
deps = [ | ||
":resize_bilinear_op", | ||
"//android/cpp/c:headers", | ||
"@org_tensorflow//tensorflow/lite/c:c_api", | ||
"@org_tensorflow//tensorflow/lite/c:c_api_experimental", | ||
"@org_tensorflow//tensorflow/lite/c:common", | ||
"@org_tensorflow//tensorflow/core:tflite_portable_logging", | ||
] + select({ | ||
"@org_tensorflow//tensorflow:android": [ | ||
"@org_tensorflow//tensorflow/lite/delegates/gpu:delegate", | ||
], | ||
"//conditions:default": [], | ||
}), | ||
alwayslink = 1, | ||
) | ||
|
||
tflite_jni_binary( | ||
name = "libtflitepixelbackend.so", | ||
exported_symbols = "//android/cpp/c:exported_symbols.lds", | ||
linkscript = "//android/cpp/c:version_script.lds", | ||
deps = [ | ||
":tflite_pixel", | ||
], | ||
) |
Oops, something went wrong.