Skip to content

Commit

Permalink
modify api of Export (#755)
Browse files Browse the repository at this point in the history
* remove code

* modify api
  • Loading branch information
jiangjiajun authored May 26, 2022
1 parent f1a26ed commit ecb52a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions paddle2onnx/converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ PADDLE2ONNX_DECL bool IsExportable(const void* model_buffer, int model_size,
}

PADDLE2ONNX_DECL bool Export(const char* model, const char* params, char** out,
int& out_size, int32_t opset_version,
int* out_size, int32_t opset_version,
bool auto_upgrade_opset, bool verbose,
bool enable_onnx_checker,
bool enable_experimental_op,
Expand All @@ -100,15 +100,15 @@ PADDLE2ONNX_DECL bool Export(const char* model, const char* params, char** out,
P2OLogger(verbose) << "The exported ONNX model is invalid!" << std::endl;
return false;
}
out_size = result.size();
*out = new char[out_size]();
std::memcpy(*out, result.data(), out_size);
*out_size = result.size();
*out = new char[*out_size]();
std::memcpy(*out, result.data(), *out_size);
return true;
}

PADDLE2ONNX_DECL bool Export(const void* model_buffer, int model_size,
const void* params_buffer, int params_size,
char** out, int& out_size, int32_t opset_version,
char** out, int* out_size, int32_t opset_version,
bool auto_upgrade_opset, bool verbose,
bool enable_onnx_checker,
bool enable_experimental_op,
Expand All @@ -127,9 +127,9 @@ PADDLE2ONNX_DECL bool Export(const void* model_buffer, int model_size,
P2OLogger(verbose) << "The exported ONNX model is invalid!" << std::endl;
return false;
}
out_size = result.size();
*out = new char[out_size]();
std::memcpy(*out, result.data(), out_size);
*out_size = result.size();
*out = new char[*out_size]();
std::memcpy(*out, result.data(), *out_size);
return true;
}
} // namespace paddle2onnx
4 changes: 2 additions & 2 deletions paddle2onnx/converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ PADDLE2ONNX_DECL bool IsExportable(
bool enable_experimental_op = false, bool enable_optimize = true);

PADDLE2ONNX_DECL bool Export(const char* model, const char* params, char** out,
int& out_size, int32_t opset_version = 11,
int* out_size, int32_t opset_version = 11,
bool auto_upgrade_opset = true,
bool verbose = false,
bool enable_onnx_checker = true,
Expand All @@ -50,7 +50,7 @@ PADDLE2ONNX_DECL bool Export(const char* model, const char* params, char** out,

PADDLE2ONNX_DECL bool Export(
const void* model_buffer, int model_size, const void* params_buffer,
int params_size, char** out, int& out_size, int32_t opset_version = 11,
int params_size, char** out, int* out_size, int32_t opset_version = 11,
bool auto_upgrade_opset = true, bool verbose = false,
bool enable_onnx_checker = true, bool enable_experimental_op = false,
bool enable_optimize = true);
Expand Down
2 changes: 1 addition & 1 deletion paddle2onnx/cpp2py_export.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PYBIND11_MODULE(paddle2onnx_cpp2py_export, m) {
P2OLogger(verbose) << "Paramters file path: " << params_filename << std::endl;
char* out = nullptr;
int size = 0;
if (!Export(model_filename.c_str(), params_filename.c_str(), &out, size,
if (!Export(model_filename.c_str(), params_filename.c_str(), &out, &size,
opset_version, auto_upgrade_opset, verbose, enable_onnx_checker,
enable_experimental_op, enable_optimize)) {
P2OLogger(verbose) << "Paddle model convert failed." << std::endl;
Expand Down

0 comments on commit ecb52a9

Please sign in to comment.