You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.9 KiB

  1. add_definitions(-DUSE_TORCH)
  2. add_definitions(-DUSE_IPEX)
  3. if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
  4. message(FATAL_ERROR "Intel Extension For PyTorch supports only Linux for now")
  5. endif()
  6. if(CXX11_ABI)
  7. set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcpu.zip")
  8. set(URL_HASH "SHA256=137a842d1cf1e9196b419390133a1623ef92f8f84dc7a072f95ada684f394afd")
  9. else()
  10. set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-2.0.1%2Bcpu.zip")
  11. set(URL_HASH "SHA256=90d50350fd24ce5cf9dfbf47888d0cfd9f943eb677f481b86fe1b8e90f7fda5d")
  12. endif()
  13. FetchContent_Declare(libtorch
  14. URL ${LIBTORCH_URL}
  15. URL_HASH ${URL_HASH}
  16. )
  17. FetchContent_MakeAvailable(libtorch)
  18. find_package(Torch REQUIRED PATHS ${libtorch_SOURCE_DIR} NO_DEFAULT_PATH)
  19. if(CXX11_ABI)
  20. set(LIBIPEX_URL "https://intel-optimized-pytorch.s3.cn-north-1.amazonaws.com.cn/libipex/cpu/libintel-ext-pt-cxx11-abi-2.0.100%2Bcpu.run")
  21. set(URL_HASH "SHA256=f172d9ebc2ca0c39cc93bb395721194f79767e1bc3f82b13e1edc07d1530a600")
  22. set(LIBIPEX_SCRIPT_NAME "libintel-ext-pt-cxx11-abi-2.0.100%2Bcpu.run")
  23. else()
  24. set(LIBIPEX_URL "https://intel-optimized-pytorch.s3.cn-north-1.amazonaws.com.cn/libipex/cpu/libintel-ext-pt-2.0.100%2Bcpu.run")
  25. set(URL_HASH "SHA256=8392f965dd9b8f6c0712acbb805c7e560e4965a0ade279b47a5f5a8363888268")
  26. set(LIBIPEX_SCRIPT_NAME "libintel-ext-pt-2.0.100%2Bcpu.run")
  27. endif()
  28. FetchContent_Declare(intel_ext_pt
  29. URL ${LIBIPEX_URL}
  30. URL_HASH ${URL_HASH}
  31. DOWNLOAD_DIR ${FETCHCONTENT_BASE_DIR}
  32. DOWNLOAD_NO_EXTRACT TRUE
  33. PATCH_COMMAND bash ${FETCHCONTENT_BASE_DIR}/${LIBIPEX_SCRIPT_NAME} install ${libtorch_SOURCE_DIR}
  34. )
  35. FetchContent_MakeAvailable(intel_ext_pt)
  36. find_package(IPEX REQUIRED PATHS ${libtorch_SOURCE_DIR} NO_DEFAULT_PATH)
  37. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS} -DC10_USE_GLOG")