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

Stash

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