Skip to content

Commit f0f1878

Browse files
committed
[Windows] misc fixes to enable Windows build
1 parent 791fe7f commit f0f1878

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

backends/xnnpack/CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,42 @@ foreach(fbs_file ${_xnnpack_schema__srcs})
7373
)
7474
endforeach()
7575

76+
if(WIN32)
77+
set(MV_COMMAND powershell -Command "Move-Item -Path ${_xnnpack_flatbuffer__outputs} -Destination ${_xnnpack_schema__outputs}")
78+
else()
79+
set(MV_COMMAND mv ${_xnnpack_flatbuffer__outputs} ${_xnnpack_schema__outputs})
80+
endif()
81+
7682
# Generate the headers from the .fbs files.
7783
add_custom_command(
7884
OUTPUT ${_xnnpack_schema__outputs}
7985
COMMAND
8086
${FLATC_EXECUTABLE} --cpp --cpp-std c++11 --scoped-enums -o
8187
"${_xnnpack_schema__include_dir}/executorch/backends/xnnpack/serialization"
8288
${_xnnpack_schema__srcs}
83-
COMMAND mv ${_xnnpack_flatbuffer__outputs} ${_xnnpack_schema__outputs}
89+
COMMAND ${MV_COMMAND}
8490
WORKING_DIRECTORY ${EXECUTORCH_ROOT}
8591
COMMENT "Generating xnnpack_schema headers"
8692
VERBATIM
8793
)
8894

95+
unset(MV_COMMAND)
96+
8997
add_library(xnnpack_schema INTERFACE ${_xnnpack_schema__outputs})
9098
set_target_properties(xnnpack_schema PROPERTIES LINKER_LANGUAGE CXX)
9199
target_include_directories(
92100
xnnpack_schema INTERFACE ${_xnnpack_schema__include_dir}
93101
${EXECUTORCH_ROOT}/third-party/flatbuffers/include
94102
)
95103

96-
set(xnnpack_third_party pthreadpool cpuinfo)
104+
set(xnnpack_third_party pthreadpool extension_threadpool cpuinfo)
97105

98106
include(cmake/Dependencies.cmake)
99107

100108
list(TRANSFORM _xnnpack_backend__srcs PREPEND "${EXECUTORCH_ROOT}/")
101109
add_library(xnnpack_backend STATIC ${_xnnpack_backend__srcs})
102110
target_link_libraries(
103-
xnnpack_backend PRIVATE ${xnnpack_third_party} executorch_core xnnpack_schema
111+
xnnpack_backend PUBLIC ${xnnpack_third_party} executorch_core xnnpack_schema
104112
)
105113

106114
target_include_directories(

extension/llm/custom_ops/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|armv7)$")
4949
list(APPEND _custom_ops__srcs
5050
"extension/llm/custom_ops/spinquant/third-party/FFHT/fht_neon.c"
5151
)
52-
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
52+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)")
5353
list(APPEND _custom_ops__srcs
5454
"extension/llm/custom_ops/spinquant/third-party/FFHT/fht_avx.c"
5555
)

install_executorch.bat

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,8 @@ rem This batch file provides a basic functionality similar to the bash script.
77

88
cd /d "%~dp0"
99

10-
rem Find the names of the python tools to use (replace with your actual python installation)
11-
if "%PYTHON_EXECUTABLE%"=="" (
12-
if "%CONDA_DEFAULT_ENV%"=="" OR "%CONDA_DEFAULT_ENV%"=="base" OR NOT EXIST "python" (
13-
set PYTHON_EXECUTABLE=python3
14-
) else (
15-
set PYTHON_EXECUTABLE=python
16-
)
17-
)
10+
rem Under windows, it's always python
11+
set PYTHON_EXECUTABLE=python
1812

1913
"%PYTHON_EXECUTABLE%" install_executorch.py %*
2014

setup.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,22 +345,28 @@ def inplace_dir(self, installer: "InstallerBuildExt") -> Path:
345345
class BuiltExtension(_BaseExtension):
346346
"""An extension that installs a python extension that was built by cmake."""
347347

348-
def __init__(self, src: str, modpath: str):
348+
def __init__(self, src: str, modpath: str, src_dir: Optional[str] = None):
349349
"""Initializes a BuiltExtension.
350350
351351
Args:
352-
src: The path to the file to install (typically a shared library),
353-
relative to the cmake-out directory. May be an fnmatch-style
354-
glob that matches exactly one file. If the path ends in `.so`,
355-
this class will also look for similarly-named `.dylib` files.
352+
src_dir: The directory of the file to install, relative to the cmake-out
353+
directory. A placeholder %BUILD_TYPE% will be replaced with the build
354+
type for multi-config generators (like Visual Studio) where the build
355+
output is in a subdirectory named after the build type. For single-
356+
config generators (like Makefile Generators or Ninja), this placeholder
357+
will be removed.
358+
src_name: The name of the file to install. If the path ends in `.so`,
356359
modpath: The dotted path of the python module that maps to the
357360
extension.
358361
"""
359362
assert (
360363
"/" not in modpath
361364
), f"modpath must be a dotted python module path: saw '{modpath}'"
365+
full_src = src
366+
if src_dir is not None:
367+
full_src = os.path.join(src_dir, src)
362368
# This is a real extension, so use the modpath as the name.
363-
super().__init__(src=f"%CMAKE_CACHE_DIR%/{src}", dst=modpath, name=modpath)
369+
super().__init__(src=f"%CMAKE_CACHE_DIR%/{full_src}", dst=modpath, name=modpath)
364370

365371
def src_path(self, installer: "InstallerBuildExt") -> Path:
366372
"""Returns the path to the source file, resolving globs.
@@ -784,7 +790,9 @@ def get_ext_modules() -> List[Extension]:
784790
# portable kernels, and a selection of backends. This lets users
785791
# load and execute .pte files from python.
786792
BuiltExtension(
787-
"_portable_lib.*", "executorch.extension.pybindings._portable_lib"
793+
src="_portable_lib.cp*",
794+
modpath="executorch.extension.pybindings._portable_lib",
795+
src_dir="%BUILD_TYPE%/",
788796
)
789797
)
790798
if ShouldBuild.training():

0 commit comments

Comments
 (0)