%global pypi_name executorch Name: python-%{pypi_name} Version: 1.3.1 Release: 0%{?dist} Summary: On-device AI across mobile, embedded and edge for PyTorch License: BSD-3-Clause URL: https://pytorch.org/executorch/ Source0: https://github.com/pytorch/executorch/archive/%{version}.tar.gz#/%{pypi_name}-%{version}.tar.gz Source1: torchcodec-rocm-prelude.cmake # Patches to use various systems libraries, the intention # is to work to get these upstream (if possible) Patch1: executorch-toplevel-system-libs.patch Patch2: executorch-use-system-libs.patch Patch3: executorch-xnnpack-dependencies.patch Patch4: executorch-xnnpack-cmakelists.patch Patch5: executorch-toplevel-tokenizers.patch Patch6: executorch-toplevel-system-pybind11.patch Patch7: executorch-toplevel-pybind-python-embed.patch Patch8: executorch-use-system-flatcc.patch Patch9: executorch-eigenblas-system.patch Patch10: executorch-pybind11-python-dev-fix.patch Patch11: executorch-coreml-pybind-python-embed.patch Patch12: executorch-system-flatc-wheel.patch ExclusiveArch: x86_64 aarch64 BuildRequires: git-core BuildRequires: gcc gcc-c++ BuildRequires: cpuinfo-devel BuildRequires: flatbuffers-devel BuildRequires: flatbuffers-compiler BuildRequires: flatcc-devel BuildRequires: flexiblas-devel BuildRequires: fxdiv-devel BuildRequires: gflags-devel BuildRequires: json-devel BuildRequires: pthreadpool-devel BuildRequires: pocketfft-devel BuildRequires: pybind11-devel BuildRequires: python3-cmake BuildRequires: python3-devel BuildRequires: python3-pip BuildRequires: python3-setuptools BuildRequires: python3-torch BuildRequires: python3-pytorch-tokenizers-devel BuildRequires: xnnpack-devel # ROCm doesn't appear to be used but is needed as torch is built with it %ifarch x86_64 BuildRequires: hipblas-devel BuildRequires: hipfft-devel BuildRequires: hiprand-devel BuildRequires: rocblas-devel BuildRequires: rocm-hip-devel BuildRequires: rocm-smi-devel BuildRequires: miopen-devel BuildRequires: hipsparse-devel BuildRequires: rocprim-devel BuildRequires: hipcub-devel BuildRequires: rocthrust-devel BuildRequires: hipsolver-devel BuildRequires: rocsolver-devel BuildRequires: hipblaslt-devel BuildRequires: hipsparselt-devel BuildRequires: rocm-runtime-devel BuildRequires: rocm-comgr-devel BuildRequires: rocrand-devel %endif Requires: flatbuffers-compiler %global _description %{expand: ExecuTorch is PyTorch's unified solution for deploying AI models on-device—from smartphones to microcontrollers—built for privacy, performance, and portability. It powers Meta's on-device AI across Instagram, WhatsApp, Quest 3, Ray-Ban Meta Smart Glasses, and more. Deploy LLMs, vision, speech, and multimodal models with the same PyTorch APIs you already know—accelerating research to production with seamless model export, optimization, and deployment. No manual C++ rewrites. No format conversions. No vendor lock-in. } %description %_description %package -n python3-%{pypi_name} Summary: %{summary} %description -n python3-%{pypi_name} %_description %prep %autosetup -p1 -n %{pypi_name}-%{version} # build expects a directory of executorch ln -s %{pypi_name}-%{version} ../%{pypi_name} # Allow for versioned executorch directories sed -i 's/STREQUAL "executorch"/MATCHES "^executorch(-.*)?$"/' CMakeLists.txt # Adjust for Fedora python version minimums sed -i 's/>=3.10,<3.14/>=3.10/' pyproject.toml # Adjust for Fedora cmake versions sed -i 's/,<4.0.0//g' pyproject.toml sed -i 's/, <4.0.0//g' requirements-dev.txt # Fedora has 1.4.x sed -i 's/mpmath==1.3.0/mpmath>=1.3.0/' pyproject.toml # Fedora has 1.8 sed -i 's/scikit-learn==1.7.1/scikit-learn>=1.7.1/' pyproject.toml # Fedora has 9.x sed -i 's/pytest<9.0/pytest/' pyproject.toml # Fedora has 15.0 sed -i 's/pytest-rerunfailures==15.1/pytest-rerunfailures==15.0/' pyproject.toml # Complements patch8 needs a better fix sed -i '/pybind11_add_module(selective_build SHARED/i find_package(Python3 COMPONENTS Interpreter Development.Embed REQUIRED)' codegen/tools/CMakeLists.txt sed -i '/pybind11_add_module($/i \ find_package(Python3 COMPONENTS Interpreter Development.Embed REQUIRED)' extension/training/CMakeLists.txt sed -i '/pybind11_add_module($/i \ find_package(Python3 COMPONENTS Interpreter Development.Embed REQUIRED)' extension/llm/runner/CMakeLists.txt install -D -m 644 %{SOURCE1} %{_builddir}/rocm-prelude.cmake %generate_buildrequires %pyproject_buildrequires %build %ifarch x86_64 export PYTORCH_ROCM_ARCH="gfx900;gfx906;gfx908;gfx90a;gfx942;gfx1030;gfx1100" %endif %cmake -DEXECUTORCH_USE_SYSTEM_LIBS=ON \ -DEXECUTORCH_BUILD_SHARED=ON \ -DEXECUTORCH_BUILD_PYBIND=OFF \ ... # the EXECUTORCH_BUILD_EXTENSION_* options you want inside libexecutorch.so %cmake_build export CMAKE_ARGS="-DEXECUTORCH_USE_SYSTEM_LIBS=ON \ -DEXECUTORCH_XNNPACK_USE_SYSTEM_LIBS=ON -DEXECUTORCH_BUILD_XNNPACK=OFF \ -DEXECUTORCH_BUILD_OPENVINO=OFF -DEXECUTORCH_BUILD_DEVTOOLS=OFF \ -DEXECUTORCH_ENABLE_EVENT_TRACER=OFF -DEXECUTORCH_BUILD_SHARED=ON \ -DEXECUTORCH_BUILD_EXTENSION_LLM=OFF -DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER=OFF \ -DEXECUTORCH_BUILD_COREML=OFF -DEXECUTORCH_BUILD_KERNELS_LLM_AOT=OFF " # Fix torchao headers: -DEXECUTORCH_BUILD_KERNELS_LLM_AOT=OFF # xnnpack needs newer rev -DEXECUTORCH_BUILD_XNNPACK=OFF # all four exist from commit 7aeb36915 (30 Oct 2024) %ifarch x86_64 export CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_PROJECT_INCLUDE=%{_builddir}/rocm-prelude.cmake" %endif %pyproject_wheel %install %cmake_install %pyproject_install %pyproject_save_files -l %{pypi_name} %files -n python3-%{pypi_name} -f %{pyproject_files} %doc README.md %changelog * Sun Oct 19 2025 Peter Robinson - 1.0.0-1 - Initial package