|
|
|
@ -64,12 +64,18 @@ paddle_error paddle_gradient_machine_create_for_inference_with_parameters(
|
|
|
|
|
modelConfigProtobuf.resize(modelConfigSize);
|
|
|
|
|
is.read(&modelConfigProtobuf[0], modelConfigSize);
|
|
|
|
|
paddle::TrainerConfig config;
|
|
|
|
|
paddle::ModelConfig modelConfig;
|
|
|
|
|
if (!config.ParseFromString(modelConfigProtobuf) || !config.IsInitialized()) {
|
|
|
|
|
return kPD_PROTOBUF_ERROR;
|
|
|
|
|
if (!modelConfig.ParseFromString(modelConfigProtobuf) ||
|
|
|
|
|
!modelConfig.IsInitialized()) {
|
|
|
|
|
return kPD_PROTOBUF_ERROR;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
modelConfig = config.model_config();
|
|
|
|
|
}
|
|
|
|
|
auto ptr = new paddle::capi::CGradientMachine();
|
|
|
|
|
ptr->machine.reset(paddle::GradientMachine::create(
|
|
|
|
|
config.model_config(), CREATE_MODE_TESTING, {paddle::PARAMETER_VALUE}));
|
|
|
|
|
modelConfig, CREATE_MODE_TESTING, {paddle::PARAMETER_VALUE}));
|
|
|
|
|
std::vector<paddle::ParameterPtr>& parameters = ptr->machine->getParameters();
|
|
|
|
|
for (auto& para : parameters) {
|
|
|
|
|
para->load(is);
|
|
|
|
|