CMakeLists.txt 1.6 KB
Newer Older
1 2 3
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)
4 5
  file(WRITE ${paddle_ipu_handler}
       "// Auto generated from CMake. DO NOT EDIT!\n\n")
6
  file(APPEND ${paddle_ipu_handler} "\#pragma once\n")
7 8 9 10 11 12
  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)
13 14 15 16
  copy_if_different(${paddle_ipu_handler} ${paddle_ipu_handler_final})

  foreach(file_path ${POPART_CANONICALIZATION_SRC})
    file(READ ${file_path} file_content)
17 18
    string(REGEX MATCHALL "(REGISTER_HANDLER)(\\()([A-Za-z0-9_]+)(,)"
                 op_handlers ${file_content})
19 20 21 22 23 24
    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 已提交
25

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
  set(IPU_BACKEND_SRC "ipu_strategy.cc" "ipu_executor.cc" "ipu_compiler.cc"
                      "ipu_backend.cc" "ipu_utils.cc")
  set(IPU_INFO_SRC "ipu_info.cc" "ipu_device.cc")

  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)
  cc_library(
    ipu_info
    SRCS ${IPU_INFO_SRC}
    DEPS popart-only enforce)
42
endif()