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

⬆️ [email protected] #722

Merged
merged 42 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
313bc67
Update TF to 2.8
CNugteren Mar 24, 2022
92a77ae
Always allocate im2col tensor in prepare stage to avoid errors
CNugteren Mar 24, 2022
f106eca
Various Bazel fixes
CNugteren Mar 25, 2022
6d66f45
Update TF submodule
CNugteren Mar 25, 2022
3d0d007
Update Android build tools version
CNugteren Mar 31, 2022
94978db
Apply xnnpack armhf fix
CNugteren Mar 31, 2022
eb746cf
More Bazel MLIR tablegen fixes
CNugteren Mar 31, 2022
c39878f
Update test case because of randomized output order
CNugteren Mar 31, 2022
a2a839d
Update PassRegistration constructors
CNugteren Mar 31, 2022
55092cc
Remove DecodeConstantPass functionality
CNugteren Mar 31, 2022
897002e
getValue -> getValues
CNugteren Mar 31, 2022
0efa3c6
Update PassRegistration constructors (part 2)
CNugteren Mar 31, 2022
0742075
Update converter passes to match with TF's passes
CNugteren Mar 31, 2022
091f731
Update flatbuffer options to toco options
CNugteren Apr 1, 2022
785441b
Fixes for padding in tablegen and .cc MLIR files
CNugteren Apr 1, 2022
991de88
Fix NHWC constant
CNugteren Apr 1, 2022
757a03f
Fix linking issue with LarqDialect object
CNugteren Apr 1, 2022
898496b
Update MLIR passes based on latest version from TF sources
CNugteren Apr 1, 2022
613fcee
Rename const dense to artih.const dense
CNugteren Apr 1, 2022
e6d9181
Change tf.resource to tf_type.resource
CNugteren Apr 1, 2022
fc559b8
Rename ConstantOp to Arith_ConstantOp in td files
CNugteren Apr 1, 2022
1466bc6
More constant -> arith.constant fixes
CNugteren Apr 1, 2022
685849c
Use `std.constant` for none values
lgeiger Apr 5, 2022
9e482e1
Fix optimization unittest
lgeiger Apr 5, 2022
c387f54
Fix `prepare-tf` test case
lgeiger Apr 5, 2022
06168dc
Implement custom constant materializer to fix constant folding
lgeiger Apr 5, 2022
340f1f5
Fix compiler warning
lgeiger Apr 5, 2022
0ad1108
Update submodule to `v2.8.0` tag
lgeiger Apr 5, 2022
d95dee3
Pin flatbuffers on CI
lgeiger Apr 6, 2022
9e86ac9
Add `lq.quantize(tfl.dequantize(x))` -> `lq.quantize(x)` pattern
lgeiger Apr 6, 2022
2ff5875
Sync `tf_tfl_passes` with upstresam TF
lgeiger Apr 6, 2022
37f05c9
Workaround end2end test failure by using random bias
lgeiger Apr 6, 2022
922a701
Remove optimize `lq.quantize(tfl.dequantize(x))` in more cases
lgeiger Apr 8, 2022
f87fc3f
TF 2.8: Update converter to sync with upstream tensorflow (#723)
lgeiger Apr 8, 2022
150904b
Replace make build system with basic CMake
CNugteren Apr 11, 2022
310f6f4
Fix the im2col_id issue properly this time
CNugteren Apr 13, 2022
3923692
Pin manylinux2010 image to TF 2.8
lgeiger Apr 13, 2022
5bf5748
Pin Windows 2019 as build environment
lgeiger Apr 13, 2022
bdb6f20
Checkin TF Addons `manylinux2010` toolchain
lgeiger Apr 13, 2022
b7d2a35
Increase timeout for Windows release builds from 6 (default) to 10 hours
CNugteren Apr 15, 2022
20e6548
Benchmark app from CMake: change name and add missing source files
CNugteren Apr 15, 2022
0a2c181
Remove timeout beyond the maximum 6 hours
CNugteren Apr 19, 2022
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
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.2
4.2.1
2 changes: 1 addition & 1 deletion .github/tools/release_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bazel build :build_pip_pkg \
--copt=-mavx \
--distinct_host_configuration=false \
--verbose_failures \
--crosstool_top=@org_tensorflow//third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010-nvcc-cuda11.2:toolchain
--crosstool_top=//third_party/toolchains/gcc7_manylinux2010-nvcc-cuda11:toolchain

# Package Whl
bazel-bin/build_pip_pkg artifacts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ jobs:
run: |
docker run -e LCE_RELEASE_VERSION=${{ github.event.inputs.version }} \
-v ${PWD}:/compute-engine -w /compute-engine \
tensorflow/build:latest-python${{ matrix.python-version }} \
tensorflow/build:2.8-python${{ matrix.python-version }} \
.github/tools/release_linux.sh

sudo apt-get -y -qq install patchelf --no-install-recommends
Expand All @@ -228,7 +228,7 @@ jobs:

windows-release-wheel:
name: Build release wheels for Windows
runs-on: windows-latest
runs-on: windows-2019
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ jobs:
run: pip install numpy --no-cache-dir
- name: Run C++ Unit Tests
run: bazelisk test larq_compute_engine/tests:cc_tests --copt=-O2 --distinct_host_configuration=false --test_output=all
- name: Build TF Lite Static Library with Make
run: larq_compute_engine/tflite/build_make/build_lce.sh --native
- name: Build TF Lite Static Library with CMake
run: |
mkdir build
cd build
cmake ..
make -j2

ARM:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -83,7 +87,7 @@ jobs:
if: github.ref != 'refs/heads/main'
shell: bash
- name: Install pip dependencies
run: pip install tensorflow-cpu~=2.6.2 larq~=0.11 larq_zoo~=2.0 pytest tensorflow_datasets~=4.2 flatbuffers tqdm --no-cache-dir
run: pip install tensorflow-cpu~=2.8.0 larq~=0.11 larq_zoo~=2.0 pytest tensorflow_datasets~=4.4 flatbuffers==1.12 tqdm --no-cache-dir
- name: Run Interpreter test
run: bazelisk test larq_compute_engine/tflite/tests:interpreter_test --test_output=all
- name: Run FileCheck tests
Expand All @@ -97,15 +101,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
tf-version: [1.14.0, 1.15.5, 2.0.4, 2.1.3, 2.2.2, 2.3.2, 2.4.1, 2.5.0, 2.6.2, 2.7.0]
tf-version: [1.14.0, 1.15.5, 2.0.4, 2.1.4, 2.2.3, 2.3.3, 2.4.4, 2.5.3, 2.6.3, 2.7.1, 2.8.0]
if: "!contains(github.event.head_commit.message, 'ci-skip')"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: 3.7
- name: Install dependencies
run: pip install tensorflow==${{matrix.tf-version}} larq~=0.11 larq_zoo~=2.0 tensorflow_datasets==1.3.2 packaging flatbuffers --no-cache-dir
run: pip install tensorflow==${{matrix.tf-version}} larq~=0.11 larq_zoo~=2.0 tensorflow_datasets==1.3.2 packaging flatbuffers==1.12 --no-cache-dir
- name: Run Converter test
run: PYTHONPATH=./ python larq_compute_engine/mlir/python/converter_test.py

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ node_modules
__pycache__
*.swp
.vscode/
cmake_build/
cmake_build*
cmake-build*
tensorflow/contrib/cmake/_build/
.idea/**
/build/
Expand Down
1 change: 1 addition & 0 deletions .tensorflow.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ build:elinux_aarch64 --config=elinux
build:elinux_aarch64 --cpu=aarch64
build:elinux_armhf --config=elinux
build:elinux_armhf --cpu=armhf
build:elinux_armhf --copt -mfp16-format=ieee
CNugteren marked this conversation as resolved.
Show resolved Hide resolved

# Address sanitizer
# CC=clang bazel build --config asan
Expand Down
96 changes: 96 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
cmake_minimum_required(VERSION 3.16)
project(larq_compute_engine C CXX)

# Options and their default values
option(COMPILE_EXAMPLE "Enable compilation of the minimal example" ON)
option(COMPILE_BENCHMARK "Enable compilation of the benchmarking utility" ON)

# TensorFlow dependency, see https://www.tensorflow.org/lite/guide/build_cmake
set(TENSORFLOW_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/third_party/tensorflow/")
set(TFLITE_SOURCE_DIR "${TENSORFLOW_SOURCE_DIR}/tensorflow/lite")
add_subdirectory("${TFLITE_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/tensorflow-lite" EXCLUDE_FROM_ALL)

# Generic compilation options and settings
set(CMAKE_CXX_STANDARD 14)
include_directories(${CMAKE_CURRENT_LIST_DIR})

# The LCE core files
set(LCE_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/larq_compute_engine")
set(LCE_CORE_SRCS
${LCE_SOURCE_DIR}/tflite/kernels/bconv2d.cc
${LCE_SOURCE_DIR}/tflite/kernels/bmaxpool.cc
${LCE_SOURCE_DIR}/tflite/kernels/quantization.cc
)
set(LCE_CORE_HDRS # such that they can be discovered by IDEs such as CLion Visual Studio
${LCE_SOURCE_DIR}/core/indirect_bgemm/kernel.h
${LCE_SOURCE_DIR}/core/indirect_bgemm/kernel_4x2_portable.h
${LCE_SOURCE_DIR}/core/indirect_bgemm/kernel_8x4x4_aarch64.h
${LCE_SOURCE_DIR}/core/indirect_bgemm/kernel_8x4x1_aarch64.h
${LCE_SOURCE_DIR}/core/indirect_bgemm/select_kernel.h
${LCE_SOURCE_DIR}/core/indirect_bgemm/kernel_8x4x2_aarch64.h
${LCE_SOURCE_DIR}/core/bmaxpool.h
${LCE_SOURCE_DIR}/core/bitpacking/utils.h
${LCE_SOURCE_DIR}/core/bitpacking/bitpack.h
${LCE_SOURCE_DIR}/core/bitpacking/bitpack_aarch64.h
${LCE_SOURCE_DIR}/core/types.h
${LCE_SOURCE_DIR}/core/bconv2d/optimized_indirect_bgemm.h
${LCE_SOURCE_DIR}/core/bconv2d/reference.h
${LCE_SOURCE_DIR}/core/bconv2d/optimized_bgemm.h
${LCE_SOURCE_DIR}/core/bconv2d/zero_padding_correction.h
${LCE_SOURCE_DIR}/core/bconv2d/params.h
${LCE_SOURCE_DIR}/core/bconv2d/output_transform.h
${LCE_SOURCE_DIR}/core/bgemm/kernels_common.h
${LCE_SOURCE_DIR}/core/bgemm/ruy_trmul_params.h
${LCE_SOURCE_DIR}/core/bgemm/kernels_aarch64.h
${LCE_SOURCE_DIR}/core/bgemm/kernels.h
${LCE_SOURCE_DIR}/core/bgemm/ruy_pack.h
${LCE_SOURCE_DIR}/core/bgemm/kernels_arm32.h
${LCE_SOURCE_DIR}/core/bgemm/bgemm.h
${LCE_SOURCE_DIR}/tflite/kernels/lce_ops_register.h
${LCE_SOURCE_DIR}/tflite/kernels/utils.h
)

# The example application
if(COMPILE_EXAMPLE)
set(LCE_EXAMPLE_SRCS ${CMAKE_CURRENT_LIST_DIR}/examples/lce_minimal.cc)
add_executable(example ${LCE_CORE_SRCS} ${LCE_CORE_HDRS} ${LCE_EXAMPLE_SRCS})
target_link_libraries(example tensorflow-lite)
endif()

# The benchmarking binary
if(COMPILE_BENCHMARK)
set(LCE_BENCHMARK_SRCS
${LCE_SOURCE_DIR}/tflite/benchmark/lce_benchmark_tflite_model.cc
${LCE_SOURCE_DIR}/tflite/benchmark/lce_benchmark_main.cc
)
set(LCE_BENCHMARK_HRDS
${LCE_SOURCE_DIR}/tflite/benchmark/lce_benchmark_tflite_model.h
${TFLITE_SOURCE_DIR}/tools/benchmark/benchmark_model.h
)
set(TFLITE_BENCHMARK_SRCS # from ${TFLITE_SOURCE_DIR}/tools/benchmark/CMakeLists.txt
${TENSORFLOW_SOURCE_DIR}/tensorflow/core/util/stats_calculator.cc
${TFLITE_SOURCE_DIR}/kernels/internal/utils/sparsity_format_converter.cc
${TFLITE_SOURCE_DIR}/profiling/memory_info.cc
${TFLITE_SOURCE_DIR}/profiling/memory_usage_monitor.cc
${TFLITE_SOURCE_DIR}/profiling/profile_summarizer.cc
${TFLITE_SOURCE_DIR}/profiling/profile_summary_formatter.cc
${TFLITE_SOURCE_DIR}/profiling/time.cc
${TFLITE_SOURCE_DIR}/tools/command_line_flags.cc
${TFLITE_SOURCE_DIR}/tools/benchmark/benchmark_model.cc
${TFLITE_SOURCE_DIR}/tools/benchmark/benchmark_performance_options.cc
${TFLITE_SOURCE_DIR}/tools/benchmark/benchmark_tflite_model.cc
${TFLITE_SOURCE_DIR}/tools/benchmark/benchmark_utils.cc
${TFLITE_SOURCE_DIR}/tools/benchmark/profiling_listener.cc
${TFLITE_SOURCE_DIR}/tools/delegates/default_execution_provider.cc
${TFLITE_SOURCE_DIR}/tools/delegates/delegate_provider.cc
${TFLITE_SOURCE_DIR}/tools/delegates/xnnpack_delegate_provider.cc
${TFLITE_SOURCE_DIR}/tools/evaluation/utils.cc
${TFLITE_SOURCE_DIR}/tools/tool_params.cc
)
add_executable(lce_benchmark_model
${TFLITE_BENCHMARK_SRCS}
${LCE_CORE_SRCS} ${LCE_CORE_HDRS}
${LCE_BENCHMARK_SRCS} ${LCE_BENCHMARK_HRDS}
)
target_link_libraries(lce_benchmark_model tensorflow-lite)
endif()
7 changes: 4 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ http_archive(
patch_tool = "patch",
patches = [
"//third_party/tensorflow_patches:disable_forced_mkl.patch",
"//third_party/tensorflow_patches:fix_armhf_xnnpack.patch",
],
sha256 = "e68c1d346fc3d529653530ca346b2c62f5b31bd4fcca7ffc9c65bb39ab2f6ed3",
strip_prefix = "tensorflow-2.6.2",
sha256 = "66b953ae7fba61fd78969a2e24e350b26ec116cf2e6a7eb93d02c63939c6f9f7",
strip_prefix = "tensorflow-2.8.0",
urls = [
"https://github.com/tensorflow/tensorflow/archive/v2.6.2.tar.gz",
"https://github.com/tensorflow/tensorflow/archive/v2.8.0.tar.gz",
],
)

Expand Down
Loading