提交 3fcd81fd 编写于 作者: Y Yu Yang

Stash

上级 aa6e2521
...@@ -26,7 +26,7 @@ find_package(NumPy REQUIRED) ...@@ -26,7 +26,7 @@ find_package(NumPy REQUIRED)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
find_package(AVX QUIET) find_package(AVX QUIET)
find_package(Glog REQUIRED) find_package(Glog REQUIRED)
find_package(Gflags REQUIRED) find_package(Gflags COMPONENTS nothreads_static REQUIRED)
find_package(GTest) find_package(GTest)
find_package(Sphinx) find_package(Sphinx)
find_package(Doxygen) find_package(Doxygen)
......
...@@ -110,7 +110,7 @@ function(link_paddle_exe TARGET_NAME) ...@@ -110,7 +110,7 @@ function(link_paddle_exe TARGET_NAME)
${METRIC_LIBS} ${METRIC_LIBS}
${PROTOBUF_LIBRARY} ${PROTOBUF_LIBRARY}
${LIBGLOG_LIBRARY} ${LIBGLOG_LIBRARY}
${GFLAGS_LIBRARIES} gflags
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${CBLAS_LIBS} ${CBLAS_LIBS}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
......
...@@ -18,7 +18,9 @@ target_include_directories(paddle_capi PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) ...@@ -18,7 +18,9 @@ target_include_directories(paddle_capi PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
add_dependencies(paddle_capi gen_proto_cpp) add_dependencies(paddle_capi gen_proto_cpp)
target_link_libraries(paddle_capi target_link_libraries(paddle_capi
"-Wl,-force_load"
paddle_gserver paddle_gserver
"-Wl,-force_load"
paddle_function paddle_function
paddle_pserver paddle_pserver
paddle_trainer_lib paddle_trainer_lib
...@@ -30,7 +32,7 @@ target_link_libraries(paddle_capi ...@@ -30,7 +32,7 @@ target_link_libraries(paddle_capi
paddle_cuda paddle_cuda
${PROTOBUF_LIBRARY} ${PROTOBUF_LIBRARY}
${LIBGLOG_LIBRARY} ${LIBGLOG_LIBRARY}
${GFLAGS_LIBRARIES} gflags
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${CBLAS_LIBS} ${CBLAS_LIBS}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
...@@ -38,7 +40,6 @@ target_link_libraries(paddle_capi ...@@ -38,7 +40,6 @@ target_link_libraries(paddle_capi
${CMAKE_DL_LIBS} ${CMAKE_DL_LIBS}
${PYTHON_LIBRARIES}) ${PYTHON_LIBRARIES})
set(PADDLE_CAPI_INC_PATH set(PADDLE_CAPI_INC_PATH
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}) ${CMAKE_CURRENT_SOURCE_DIR})
......
...@@ -26,18 +26,4 @@ int PDInit(int argc, char** argv) { ...@@ -26,18 +26,4 @@ int PDInit(int argc, char** argv) {
free(realArgv[0]); free(realArgv[0]);
return PD_NO_ERROR; return PD_NO_ERROR;
} }
int PDParseTrainerConfigFromFile(char* filename,
void** modelConfigProtobuf,
int* size) {
if (filename == nullptr || modelConfigProtobuf == nullptr || size == nullptr)
return PD_NULLPTR;
paddle::TrainerConfigHelper conf(filename);
if (!conf.getConfig().IsInitialized()) return PD_PROTOBUF_ERROR;
*size = conf.getConfig().ByteSize();
*modelConfigProtobuf = malloc(*size);
if (!conf.getConfig().SerializeToArray(*modelConfigProtobuf, *size))
return PD_PROTOBUF_ERROR;
return PD_NO_ERROR;
}
} }
...@@ -61,10 +61,6 @@ int PDGradientMachineDestroy(PD_GradiemtMachine machine); ...@@ -61,10 +61,6 @@ int PDGradientMachineDestroy(PD_GradiemtMachine machine);
int PDInit(int argc, char** argv); int PDInit(int argc, char** argv);
int PDParseTrainerConfigFromFile(char* filename,
void** modelConfigProtobuf,
int* size);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -13,7 +13,6 @@ function(add_capi_unittest_without_exec TARGET_NAME) ...@@ -13,7 +13,6 @@ function(add_capi_unittest_without_exec TARGET_NAME)
${TARGET_NAME} ${TARGET_NAME}
${sources}) ${sources})
target_link_libraries( target_link_libraries(
${TARGET_NAME} ${TARGET_NAME}
paddle_capi paddle_capi
......
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <paddle/trainer/TrainerConfigHelper.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "PaddleCAPI.h" #include "PaddleCAPI.h"
TEST(GradientMachine, load) { TEST(GradientMachine, load) {
void* buf; paddle::TrainerConfigHelper config("./vgg_16_cifar.py");
int size; std::string buffer;
ASSERT_EQ( ASSERT_TRUE(config.getModelConfig().SerializeToString(&buffer));
PD_NO_ERROR, PD_GradiemtMachine machine;
PDParseTrainerConfigFromFile(strdup("./vgg_16_cifar.py"), &buf, &size));
free(buf); ASSERT_EQ(PD_NO_ERROR,
PDGradientMachineCreateForPredict(
&machine, &buffer[0], (int)buffer.size()));
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册