test_GradientMachine.cpp 749 字节
Newer Older
Y
Yu Yang 已提交
1
#include <gtest/gtest.h>
Y
Stash  
Yu Yang 已提交
2
#include <paddle/trainer/TrainerConfigHelper.h>
Y
Yu Yang 已提交
3 4 5 6 7
#include <stdlib.h>
#include <string.h>
#include "PaddleCAPI.h"

TEST(GradientMachine, load) {
Y
Stash  
Yu Yang 已提交
8 9 10 11 12 13 14 15
  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()));
Y
Yu Yang 已提交
16 17 18 19 20 21 22 23 24 25 26 27
}

int main(int argc, char** argv) {
  testing::InitGoogleTest(&argc, argv);
  std::vector<char*> argvs;
  argvs.push_back(strdup("--use_gpu=false"));
  PDInit((int)argvs.size(), argvs.data());
  for (auto each : argvs) {
    free(each);
  }
  return RUN_ALL_TESTS();
}