Skip to content

Commit 89aed7b

Browse files
authored
Add ImageProcessor library to ExecuTorch (pytorch#19967)
Differential Revision: D106898421 Pull Request resolved: pytorch#19967
1 parent 447e317 commit 89aed7b

16 files changed

Lines changed: 2268 additions & 0 deletions

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,11 @@ if(EXECUTORCH_BUILD_EXTENSION_TENSOR)
864864
list(APPEND _executorch_extensions extension_tensor)
865865
endif()
866866

867+
if(EXECUTORCH_BUILD_EXTENSION_IMAGE)
868+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/image)
869+
list(APPEND _executorch_extensions extension_image)
870+
endif()
871+
867872
if(EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_CPUINFO)
868873
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/threadpool)
869874
endif()

extension/image/BUCK

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load(":targets.bzl", "define_common_targets")
2+
3+
oncall("executorch")
4+
5+
define_common_targets()

extension/image/CMakeLists.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
cmake_minimum_required(VERSION 3.19)
8+
9+
# stb_image_resize: lightweight header-only library used by the resize step in
10+
# image_processor.cpp.
11+
include(FetchContent)
12+
FetchContent_Declare(
13+
stb
14+
GIT_REPOSITORY https://github.com/nothings/stb.git
15+
GIT_TAG f0569113c93ad095470c54bf34a17b36646bbbb5
16+
)
17+
FetchContent_MakeAvailable(stb)
18+
19+
add_library(extension_image image_processor_common.cpp image_processor.cpp)
20+
21+
target_include_directories(
22+
extension_image PUBLIC ${_common_include_directories}
23+
)
24+
25+
# stb_image_resize.h lives under deprecated/ in current stb. Private: only the
26+
# .cpp uses it, not the installed public headers.
27+
target_include_directories(
28+
extension_image PRIVATE ${stb_SOURCE_DIR} ${stb_SOURCE_DIR}/deprecated
29+
)
30+
31+
target_link_libraries(extension_image PUBLIC executorch_core extension_tensor)
32+
33+
install(
34+
TARGETS extension_image
35+
EXPORT ExecuTorchTargets
36+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
37+
)
38+
39+
install(FILES image_processor.h image_processor_config.h
40+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/executorch/extension/image
41+
)
42+
43+
if(BUILD_TESTING)
44+
add_subdirectory(test)
45+
endif()

extension/image/TARGETS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load(":targets.bzl", "define_common_targets")
2+
3+
oncall("executorch")
4+
5+
define_common_targets()

0 commit comments

Comments
 (0)