wrongtest commented on a change in pull request #4459: [RUNTIME] Implement TVMDSOOp(TensorFlow custom op) for TVM runtime URL: https://github.com/apache/incubator-tvm/pull/4459#discussion_r367284381
########## File path: cmake/modules/contrib/TFOP.cmake ########## @@ -0,0 +1,46 @@ + +if(NOT USE_TFOP STREQUAL "OFF") + + # If want build this directly comment out below lines. + # if ("${TVM_HOME}" STREQUAL "") + # message(FATAL_ERROR "TVM_HOME is not defined") + # else() + # message("Use TVM_HOME=\"${TVM_HOME}\"") + #endif() + # include_directories(${TVM_HOME}/include) + # include_directories(${TVM_HOME}/3rdparty/dlpack/include) + # include_directories(${TVM_HOME}/3rdparty/dmlc-core/include) + # set(TFTVM_LINK_FLAGS -ltvm_runtime -L${TVM_HOME}/build) + + execute_process(COMMAND python -c "import tensorflow as tf; print(' '.join(tf.sysconfig.get_compile_flags()))" + OUTPUT_VARIABLE TF_COMPILE_FLAGS_STR + RESULT_VARIABLE TF_STATUS) + if (NOT ${TF_STATUS} EQUAL 0) + message(FATAL_ERROR "Fail to get TensorFlow compile flags") + endif() + + execute_process(COMMAND python -c "import tensorflow as tf; print(' '.join(tf.sysconfig.get_link_flags()))" + OUTPUT_VARIABLE TF_LINK_FLAGS_STR + RESULT_VARIABLE TF_STATUS) + if (NOT ${TF_STATUS} EQUAL 0) + message(FATAL_ERROR "Fail to get TensorFlow link flags") + endif() + + string(REGEX REPLACE "\n" " " TF_FLAGS "${TF_COMPILE_FLAGS} ${TF_LINK_FLAGS}") + separate_arguments(TF_COMPILE_FLAGS UNIX_COMMAND ${TF_COMPILE_FLAGS_STR}) + separate_arguments(TF_LINK_FLAGS UNIX_COMMAND ${TF_LINK_FLAGS_STR}) + + + set(OP_LIBRARY_NAME tvm_dso_op) + file(GLOB_RECURSE TFTVM_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/contrib/tf_op/*.cc) + add_library(${OP_LIBRARY_NAME} SHARED ${TFTVM_SRCS}) + set_target_properties(${OP_LIBRARY_NAME} PROPERTIES PREFIX "") + set(TFTVM_LINK_FLAGS -ltvm -L${CMAKE_CURRENT_BINARY_DIR}) Review comment: > must we needed to link full tvm library? if we could restrict only link tvm runtime, i.e.`libtvm_runtime`, we could use it easily in other platforms easily, like arm. Because many arm devices can not build tvm but could build runtime successfully because of compiler reason. Currently we cannot link to `libtvm_runtime`. Because we find python statement ```python from tvm.contrib import ... ``` will implicitly load `libtvm.so`, if we link our module to `libtvm_runtime.so`, we will get a symbol redefinition error at runtime. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services