CMakeLists.txt 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
if(WITH_IPU)
  set(paddle_ipu_handler ${CMAKE_CURRENT_BINARY_DIR}/paddle_ipu_handler.h.tmp)
  set(paddle_ipu_handler_final ${CMAKE_CURRENT_BINARY_DIR}/paddle_ipu_handler.h)
  file(WRITE ${paddle_ipu_handler} "// Auto generated from CMake. DO NOT EDIT!\n\n")
  file(APPEND ${paddle_ipu_handler} "\#pragma once\n")
  file(APPEND ${paddle_ipu_handler} "\#include \"paddle/fluid/platform/device/ipu/popart_canonicalization/canonicalization_utils.h\"\n\n")
  file(GLOB POPART_CANONICALIZATION_SRC ${CMAKE_CURRENT_SOURCE_DIR}/popart_canonicalization/*.cc)
  copy_if_different(${paddle_ipu_handler} ${paddle_ipu_handler_final})

  foreach(file_path ${POPART_CANONICALIZATION_SRC})
    file(READ ${file_path} file_content)
    string(REGEX MATCHALL "(REGISTER_HANDLER)(\\()([A-Za-z0-9_]+)(,)" op_handlers ${file_content})
    string(REPLACE "REGISTER_HANDLER(" "" op_handlers "${op_handlers}")
    string(REPLACE "," "" op_handlers "${op_handlers}")
    foreach(op_handler ${op_handlers})
      file(APPEND ${paddle_ipu_handler} "USE_HANDLER(${op_handler});\n")
    endforeach()
  endforeach()
  
A
Allen Guo 已提交
20 21 22 23 24 25 26
  set(IPU_BACKEND_SRC
    "ipu_strategy.cc"
    "ipu_executor.cc"
    "ipu_compiler.cc"
    "ipu_backend.cc"
    "ipu_utils.cc"
  )
A
Allen Guo 已提交
27 28 29 30
  set(IPU_INFO_SRC
    "ipu_info.cc"
    "ipu_device.cc"
  )
A
Allen Guo 已提交
31

32 33
  cc_library(popart_canonicalization SRCS ${POPART_CANONICALIZATION_SRC} DEPS graph)
  cc_library(ipu_backend SRCS ${IPU_BACKEND_SRC} DEPS popart-only graph graph_helper popdist popart_canonicalization)
A
Allen Guo 已提交
34
  cc_library(ipu_info SRCS ${IPU_INFO_SRC} DEPS popart-only enforce)
35
endif()