|
|
|
@ -18,33 +18,21 @@ limitations under the License. */
|
|
|
|
|
#include "paddle/inference/inference.h"
|
|
|
|
|
|
|
|
|
|
DEFINE_string(dirname, "", "Directory of the inference model.");
|
|
|
|
|
DEFINE_string(feed_var_names, "", "Names of feeding variables");
|
|
|
|
|
DEFINE_string(fetch_var_names, "", "Names of fetching variables");
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
|
google::ParseCommandLineFlags(&argc, &argv, true);
|
|
|
|
|
if (FLAGS_dirname.empty() || FLAGS_feed_var_names.empty() ||
|
|
|
|
|
FLAGS_fetch_var_names.empty()) {
|
|
|
|
|
if (FLAGS_dirname.empty()) {
|
|
|
|
|
// Example:
|
|
|
|
|
// ./example --dirname=recognize_digits_mlp.inference.model
|
|
|
|
|
// --feed_var_names="x"
|
|
|
|
|
// --fetch_var_names="fc_2.tmp_2"
|
|
|
|
|
std::cout << "Usage: ./example --dirname=path/to/your/model "
|
|
|
|
|
"--feed_var_names=x --fetch_var_names=y"
|
|
|
|
|
<< std::endl;
|
|
|
|
|
std::cout << "Usage: ./example --dirname=path/to/your/model" << std::endl;
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::cout << "FLAGS_dirname: " << FLAGS_dirname << std::endl;
|
|
|
|
|
std::cout << "FLAGS_feed_var_names: " << FLAGS_feed_var_names << std::endl;
|
|
|
|
|
std::cout << "FLAGS_fetch_var_names: " << FLAGS_fetch_var_names << std::endl;
|
|
|
|
|
|
|
|
|
|
std::string dirname = FLAGS_dirname;
|
|
|
|
|
std::vector<std::string> feed_var_names = {FLAGS_feed_var_names};
|
|
|
|
|
std::vector<std::string> fetch_var_names = {FLAGS_fetch_var_names};
|
|
|
|
|
|
|
|
|
|
paddle::InferenceEngine* engine = new paddle::InferenceEngine();
|
|
|
|
|
engine->LoadInferenceModel(dirname, feed_var_names, fetch_var_names);
|
|
|
|
|
engine->LoadInferenceModel(dirname);
|
|
|
|
|
|
|
|
|
|
paddle::framework::LoDTensor input;
|
|
|
|
|
srand(time(0));
|
|
|
|
|