Skip to content

Commit b3240d2

Browse files
committed
Merge branch 'main' into fork/vawale/add-cmake-for-onnx-app
2 parents 4207cbd + c98f92b commit b3240d2

File tree

14 files changed

+91
-71
lines changed

14 files changed

+91
-71
lines changed

.github/workflows/pip.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ jobs:
5959
fetch-depth: 0
6060
fetch-tags: true
6161

62-
# See: https://github.com/pypa/setuptools-scm/issues/455
63-
- name: Suppress git version tag
64-
if: github.event_name == 'push' && github.ref_name == 'main'
65-
run: |
66-
echo 'local_scheme = "no-local-version"' >> pyproject.toml
67-
git update-index --assume-unchanged pyproject.toml
68-
6962
- uses: ilammy/msvc-dev-cmd@v1
7063
- uses: lukka/[email protected]
7164

@@ -210,12 +203,17 @@ jobs:
210203
env:
211204
CIBW_BUILD: "cp3*-${{ matrix.platform_tag }}"
212205
CIBW_SKIP: "cp3{5,6,7,8}*"
206+
# Suppress the git version tag (necessary for TestPyPI)
207+
CIBW_ENVIRONMENT: >
208+
SETUPTOOLS_SCM_OVERRIDES_FOR_HALIDE='{local_scheme="no-local-version"}'
213209
CIBW_ENVIRONMENT_MACOS: >
214210
CMAKE_PREFIX_PATH='${{ github.workspace }}/opt'
215211
Python_ROOT_DIR=''
212+
SETUPTOOLS_SCM_OVERRIDES_FOR_HALIDE='{local_scheme="no-local-version"}'
216213
CIBW_ENVIRONMENT_WINDOWS: >
217214
CMAKE_GENERATOR=Ninja
218215
CMAKE_PREFIX_PATH='${{ github.workspace }}\opt'
216+
SETUPTOOLS_SCM_OVERRIDES_FOR_HALIDE='{local_scheme="no-local-version"}'
219217
CIBW_MANYLINUX_X86_64_IMAGE: "ghcr.io/halide/manylinux_2_28_x86_64-llvm:${{ env.LLVM_VERSION }}"
220218
CIBW_TEST_COMMAND: >
221219
cmake -G Ninja -S {project}/python_bindings/apps -B build -DCMAKE_BUILD_TYPE=Release &&

.github/workflows/presubmit.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
- '**.h'
99
- '**.c'
1010
- '**.cpp'
11+
- '**CMakeLists.txt'
12+
- '**.cmake'
1113
- 'run-clang-tidy.sh'
1214
- 'run-clang-format.sh'
1315
- '.github/workflows/presubmit.yml'

apps/hannk/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ set(CMAKE_CXX_EXTENSIONS NO)
2929
# (We need to do this even if HANNK_BUILD_TFLITE is off,
3030
# so that the .tflite file parser can get the right schema)
3131
set(TFLITE_VERSION_MAJOR "2" CACHE STRING "Major version of TFLite to assume")
32-
set(TFLITE_VERSION_MINOR "8" CACHE STRING "Minor version of TFLite to assume")
33-
set(TFLITE_VERSION_PATCH "3" CACHE STRING "Patch version of TFLite to assume")
32+
set(TFLITE_VERSION_MINOR "19" CACHE STRING "Minor version of TFLite to assume")
33+
set(TFLITE_VERSION_PATCH "0" CACHE STRING "Patch version of TFLite to assume")
3434
set(TFLITE_VERSION "${TFLITE_VERSION_MAJOR}.${TFLITE_VERSION_MINOR}.${TFLITE_VERSION_PATCH}")
3535

3636
# ----------------------------

apps/hannk/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ clean:
5959
# ---------------------- TFLite glue
6060

6161
TFLITE_VERSION_MAJOR ?= 2
62-
TFLITE_VERSION_MINOR ?= 8
63-
TFLITE_VERSION_PATCH ?= 3
62+
TFLITE_VERSION_MINOR ?= 19
63+
TFLITE_VERSION_PATCH ?= 0
6464

6565
TFLITE_VERSION = $(TFLITE_VERSION_MAJOR).$(TFLITE_VERSION_MINOR).$(TFLITE_VERSION_PATCH)
6666
TFLITE_TAG = v$(TFLITE_VERSION)

apps/hannk/tflite/CMakeLists.txt

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,49 +20,49 @@ set(FLATBUFFERS_BUILD_FLATC OFF)
2020
# Enable this to see details about downloading -- useful for debugging
2121
# set(FETCHCONTENT_QUIET NO)
2222

23-
FetchContent_Declare(tflite
24-
GIT_REPOSITORY https://github.com/tensorflow/tensorflow
25-
GIT_TAG ${TFLITE_TAG}
26-
GIT_SHALLOW TRUE)
23+
# tflite includes neon2sse transitively, but it's pinned to an old version
24+
# that declares a minimum CMake version of 3.0. We override it here to a
25+
# new enough version that CMake 4+ won't refuse to build it.
26+
FetchContent_Declare(
27+
neon2sse
28+
GIT_REPOSITORY https://github.com/intel/ARM_NEON_2_x86_SSE
29+
GIT_TAG 4732aac1e6c02984a12635d85c4644c2ffe585ca
30+
GIT_SHALLOW TRUE
31+
)
32+
33+
FetchContent_Declare(
34+
tflite
35+
GIT_REPOSITORY https://github.com/tensorflow/tensorflow
36+
GIT_TAG ${TFLITE_TAG}
37+
GIT_SHALLOW TRUE
38+
SOURCE_SUBDIR tensorflow/lite/c
39+
)
40+
41+
block(SCOPE_FOR POLICIES VARIABLES)
42+
# Suppress warnings about rotting CMake code we don't control
43+
set(CMAKE_POLICY_DEFAULT_CMP0135 OLD) # DOWNLOAD_EXTRACT_TIMESTAMP
44+
set(CMAKE_POLICY_DEFAULT_CMP0169 OLD) # FetchContent_Populate
45+
set(CMAKE_POLICY_DEFAULT_CMP0177 OLD) # install() path normalization
46+
47+
# Configuration for tflite + upstream deps
48+
set(ABSL_PROPAGATE_CXX_STD ON)
49+
50+
# Suppress warnings in tflite code
51+
add_compile_options(
52+
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-anon-enum-enum-conversion>
53+
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-deprecated-this-capture>
54+
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-shadow-uncaptured-local>
55+
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-shadow>
56+
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-tautological-type-limit-compare>
57+
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-unused-template>
58+
)
59+
60+
FetchContent_MakeAvailable(tflite)
61+
62+
set_property(TARGET tensorflowlite_c PROPERTY EXCLUDE_FROM_ALL TRUE)
63+
endblock()
2764

2865
FetchContent_GetProperties(tflite)
29-
if (NOT tflite_POPULATED)
30-
FetchContent_Populate(tflite)
31-
# Some of the subprojects (e.g. Eigen) are very noisy and emit status messages all the time.
32-
# Temporary ignore status messages while adding this to silence it. Ugly but effective.
33-
set(OLD_CMAKE_MESSAGE_LOG_LEVEL ${CMAKE_MESSAGE_LOG_LEVEL})
34-
set(CMAKE_MESSAGE_LOG_LEVEL WARNING)
35-
add_subdirectory(${tflite_SOURCE_DIR}/tensorflow/lite/c ${tflite_BINARY_DIR})
36-
set(CMAKE_MESSAGE_LOG_LEVEL ${OLD_CMAKE_MESSAGE_LOG_LEVEL})
37-
endif ()
38-
39-
# tensorflowlite_c is implicitly declared by this FetchContent.
40-
# Mark it as EXCLUDE_FROM_ALL so that it won't be built unless we actually
41-
# depend on it (which we might not depending on HANNK_BUILD_TFLITE)
42-
set_property(TARGET tensorflowlite_c PROPERTY EXCLUDE_FROM_ALL TRUE)
43-
44-
# Disable some noisy warnings in abseil
45-
foreach (LIB IN ITEMS
46-
absl_base
47-
absl_graphcycles_internal
48-
absl_malloc_internal
49-
absl_synchronization
50-
absl_time
51-
absl_time_zone)
52-
target_compile_options(${LIB}
53-
PRIVATE
54-
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-tautological-type-limit-compare>
55-
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-unused-template>
56-
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-shadow>
57-
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-shadow-uncaptured-local>
58-
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-anon-enum-enum-conversion>)
59-
endforeach ()
60-
61-
# Disable some noisy warnings in tflite
62-
target_compile_options(tensorflow-lite
63-
PRIVATE
64-
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-gnu-inline-cpp-without-extern>
65-
$<$<CXX_COMPILER_ID:GNU>:-Wno-ignored-attributes>)
6666

6767
# Make an interface library that is just to get the tflite headers,
6868
# without any implied linkage

cmake/HalideGeneratorHelpers.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ function(add_halide_generator TARGET)
6868
add_custom_target("${ARG_PACKAGE_NAME}")
6969
endif ()
7070

71-
if (NOT Halide_FOUND)
72-
find_package(Halide REQUIRED)
73-
endif ()
74-
7571
if (ARG_SOURCES MATCHES ".py$")
7672
if (ARG_LINK_LIBRARIES)
7773
message(FATAL_ERROR "You cannot specify LINK_LIBRARIES in conjunction with Python source code.")
@@ -94,6 +90,10 @@ function(add_halide_generator TARGET)
9490
else ()
9591
add_executable(${TARGET} ${ARG_SOURCES})
9692
add_executable(${gen} ALIAS ${TARGET})
93+
94+
if (NOT TARGET Halide::Generator)
95+
find_package(Halide REQUIRED)
96+
endif ()
9797
target_link_libraries(${TARGET} PRIVATE Halide::Generator ${ARG_LINK_LIBRARIES})
9898

9999
_Halide_place_dll(${TARGET})
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
cmake_minimum_required(VERSION 3.28)
22

33
include(CMakeFindDependencyMacro)
4-
find_dependency(Python 3)
4+
find_dependency(
5+
Python 3
6+
COMPONENTS Interpreter Development.Module
7+
)
58

69
include("${Python_SITEARCH}/halide/@INSTALL_DIR@/@[email protected]")

pyproject.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
requires = [
33
"pybind11>=2.11.1",
44
"scikit-build-core==0.11.5",
5+
"setuptools-scm>=8.3.1",
56
]
67
build-backend = "scikit_build_core.build"
78

@@ -66,6 +67,9 @@ dev = [
6667
"scikit-build-core==0.11.5",
6768
"setuptools-scm>=8.3.1",
6869
]
70+
apps = [
71+
"onnx"
72+
]
6973
tools = [
7074
"cmake>=3.28",
7175
"ninja>=1.11",
@@ -111,6 +115,9 @@ if.platform-system = "^win32"
111115
inherit.cmake.define = "append"
112116
cmake.define.Halide_WASM_BACKEND = "OFF"
113117

118+
[tool.setuptools_scm]
119+
# Needs to exist for scikit-build-core to use setuptools_scm
120+
114121
[tool.ruff.lint]
115122
# docs: https://docs.astral.sh/ruff/rules/
116123
select = [
@@ -165,7 +172,3 @@ search = "#define HALIDE_VERSION_MINOR {current_version}"
165172
src = "src/runtime/HalideRuntime.h"
166173
version_template = "{patch}"
167174
search = "#define HALIDE_VERSION_PATCH {current_version}"
168-
169-
# Must be last table in file since pip.yml appends to it
170-
# See: https://github.com/pypa/setuptools-scm/issues/455
171-
[tool.setuptools_scm]

requirements.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This file was autogenerated by uv via the following command:
2-
# uv export --all-groups --no-hashes --no-emit-project --format requirements-txt
2+
# uv export --all-groups --no-hashes --no-emit-project -o requirements.txt
33
cli-ui==0.19.0
44
# via tbump
55
cmake==4.0.3
@@ -18,14 +18,18 @@ numpy==2.0.2 ; python_full_version < '3.10'
1818
# via
1919
# halide
2020
# imageio
21+
# onnx
2122
numpy==2.2.6 ; python_full_version == '3.10.*'
2223
# via
2324
# halide
2425
# imageio
25-
numpy==2.3.1 ; python_full_version >= '3.11'
26+
# onnx
27+
numpy==2.3.2 ; python_full_version >= '3.11'
2628
# via
2729
# halide
2830
# imageio
31+
# onnx
32+
onnx==1.18.0
2933
packaging==25.0
3034
# via
3135
# scikit-build-core
@@ -34,8 +38,10 @@ pathspec==0.12.1
3438
# via scikit-build-core
3539
pillow==11.3.0
3640
# via imageio
41+
protobuf==6.31.1
42+
# via onnx
3743
pybind11==3.0.0
38-
ruff==0.12.4
44+
ruff==0.12.7
3945
schema==0.7.7
4046
# via tbump
4147
scikit-build-core==0.11.5
@@ -51,9 +57,10 @@ tomli==2.2.1 ; python_full_version < '3.11'
5157
# setuptools-scm
5258
tomlkit==0.11.8
5359
# via tbump
54-
typing-extensions==4.14.1 ; python_full_version < '3.11'
60+
typing-extensions==4.14.1
5561
# via
5662
# exceptiongroup
63+
# onnx
5764
# setuptools-scm
5865
unidecode==1.4.0
5966
# via cli-ui

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ if (WITH_SERIALIZATION)
551551
add_custom_command(
552552
OUTPUT "${fb_header}"
553553
COMMAND flatbuffers::flatc --cpp --cpp-std C++17 --no-union-value-namespacing --keep-prefix --filename-suffix ".fbs" -o "${fb_dir}" "${fb_def}"
554-
DEPENDS "${fb_def}"
554+
DEPENDS flatbuffers::flatc "${fb_def}"
555555
VERBATIM
556556
)
557557
add_custom_target(generate_fb_header DEPENDS "${fb_header}")

0 commit comments

Comments
 (0)