Conversation
| endif(APPLE) | ||
|
|
||
| set(ANAKIN_INCLUDE "" CACHE STRING "root of Anakin header files") | ||
| set(ANAKIN_LIBRARY "" CACHE STRING "path of Anakin library") |
There was a problem hiding this comment.
可以仿照TENSORRT和CUDNN一样,合并成一个ANAKIN_ROOT么,然后自动��include和lib。
Lines 5 to 16 in 71f51ff
There was a problem hiding this comment.
暂时不行。。 阿拉金的库比较乱
- 接口没有封装,要依赖整个 repo 的头文件
- library 需要手动拷,和完整 repo 的头文件没有放在一起
- 他们的
paddle_api.h是个 test,没有包含在发布的头文件里
所以,现在必须显式下载 library,和完整的 github repo,分别设定路径,才能编译
后面会让他们改,这个可能是临时方案。
| @@ -17,6 +17,36 @@ if(APPLE) | |||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pessimizing-move") | |||
| endif(APPLE) | |||
There was a problem hiding this comment.
可以单独一个anakin.cmake,paddle中所有第三方库加入的时候,都单独做了一个cmake,这样会更加清晰。
20-42行可以放进anakin.cmake中。
There was a problem hiding this comment.
后面可以看看,暂时他们的代码也有挺多问题的,现在给的接口也非常初步。。
There was a problem hiding this comment.
单独的anakin.cmake里面也可以显示设置include和lib
There was a problem hiding this comment.
可以等稍微成熟些再改地正规些,我感觉需要再跟他们沟通下。
目前的状态太初步了,他们的头文件我自己也改了很多地方才能用,后面应该他们要有大的修正才正式用起来。
| set(inference_deps paddle_inference_api paddle_fluid_api) | ||
|
|
||
| # if anakin is set enable anakin api implementation | ||
| if (NOT ANAKIN_INCLUDE STREQUAL "") |
There was a problem hiding this comment.
if(ANAKIN_INCLUDE_DIR AND ANAKIN_LIBRARY)
set(ANAKIN_FOUND ON)
else()
set(ANAKIN_FOUND OFF)
endif()
需要一个ANAKIN_FOUND的开关
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=switch") | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=return-type") | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=non-virtual-dtor") | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=cpp") |
There was a problem hiding this comment.
28-35行可以合并成:
if(ANAKIN_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
-Wno-error=comment
-Wno-error=reorder
-Wno-error=format
...")
| inference_api_test(test_paddle_inference_api_impl | ||
| ARGS test_word2vec test_image_classification) | ||
|
|
||
| if (NOT ANAKIN_INCLUDE STREQUAL "") |
| const std::vector<PaddleTensor> &inputs, | ||
| std::vector<PaddleTensor> *output_data) { | ||
| for (const auto &input : inputs) { | ||
| CHECK(input.dtype == PaddleDType::FLOAT32); |
|
|
||
| PaddleInferenceAnakinPredictor::PaddleInferenceAnakinPredictor( | ||
| const AnakinConfig &config) { | ||
| CHECK(Init(config)); |
There was a problem hiding this comment.
Do this in CreateXXX and return false?
There was a problem hiding this comment.
Currently, Anakin engine's creation is just a void function.
| // TODO(Superjomn) Tell anakin to support return code. | ||
| engine_.Execute(); | ||
|
|
||
| CHECK(!output_data->empty()) |
There was a problem hiding this comment.
maybe not need to worry about it?
There was a problem hiding this comment.
I found some issue about the usage of the output_data. The current implementation for the native engine is that the output_data's memory is maintained by the engine, but the original intention is to force the users to maintain the memory outside and the engine just copies the data.
So that, it can support
- fetch any target, just set the PaddleTensor's names of
output_data-- given a big model, fetch any variable - engines like Anakin's output variables are located at GPU, need a memory to copied, and users can do some memory optimization such as pre-allocate a big buffer.
| auto *tensor = engine_.GetOutputInGPU(output.name); | ||
| output.shape = tensor->shape(); | ||
| // Copy data from GPU -> CPU | ||
| CHECK_EQ(cudaMemcpy(output.data.data, |
| # if anakin is set enable anakin api implementation | ||
| if (NOT ANAKIN_INCLUDE STREQUAL "") | ||
| # Anakin's code style doesn't follow google c style. | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=comment") |
There was a problem hiding this comment.
Does this affect other codes outside anakin?
There was a problem hiding this comment.
yes, if Anakin is turn on. @luotao1 any solution?
There was a problem hiding this comment.
请问是我们使用anakin头文件的时候,会出现各种错误么?
There was a problem hiding this comment.
这几个 warning 都会编译失败,代码问题比较多,现在是会嵌套 include 他们所有的头文件,会有这类 warning.
There was a problem hiding this comment.
有一个办法,是可以不改cmake_cxx_flags。
- 参考 https://eigen.tuxfamily.org/dox/DisableStupidWarnings_8h_source.html
新增一个DisableStupidWarnings.h的头文件,将所有的warning以#pragma GCC diagnostic ignored "-Wignored-attributes"形式给去掉,加载anakin的头文件时,同步加载这个头文件。或者直接写进anakin的头文件中。 - 我在使用ICC编译器时,会出现Intel编译器一堆warning的问题,亲测有效。
| @@ -17,6 +17,36 @@ if(APPLE) | |||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pessimizing-move") | |||
| endif(APPLE) | |||
There was a problem hiding this comment.
单独的anakin.cmake里面也可以显示设置include和lib
Code of Anakin's paddle interface is a little mess, I changed some and will give a PR to its repo latter.
wgetthe Anakin library from somewhere in CI phrase or just run it manually offline?