diff --git a/mace/examples/cli/example.cc b/mace/examples/cli/example.cc index ec93674e8ec680605742cd61a9556d42ea7bd291..4892baf2e3a1dbc69f688b76a34f7d7a7a21f7dd 100644 --- a/mace/examples/cli/example.cc +++ b/mace/examples/cli/example.cc @@ -113,7 +113,7 @@ DEFINE_string(opencl_parameter_file, "tuned OpenCL parameter file path"); DEFINE_string(model_data_file, "", - "model data file name, used when EMBED_MODEL_DATA set to 0"); + "model data file name, used when model_data_format == file"); DEFINE_string(model_file, "", "model file name, used when load mace model in pb"); @@ -194,9 +194,11 @@ bool RunModel(const std::vector &input_names, // Create Engine std::shared_ptr engine; MaceStatus create_engine_status; - // Only choose one of the two type based on the `build_type` + // Only choose one of the two type based on the `model_graph_format` // in model deployment file(.yml). #ifdef MODEL_GRAPH_FORMAT_CODE + // if model_data_format == code, just pass an empty string("") + // to model_data_file parameter. create_engine_status = CreateMaceEngineFromCode(FLAGS_model_name, FLAGS_model_data_file, diff --git a/mace/public/mace.h b/mace/public/mace.h index 9a35da5bd1afb3e26d9b0bb9908072bd3572b4ee..f6116348f7f5874021271fd04feb680c615df4c7 100644 --- a/mace/public/mace.h +++ b/mace/public/mace.h @@ -127,6 +127,19 @@ class __attribute__((visibility("default"))) MaceEngine { MaceEngine &operator=(const MaceEngine &) = delete; }; +/// \brief Create MaceEngine from files (model file + data file) +/// +/// Create MaceEngine object +/// +/// \param model_pb[in]: the content of model graph file +/// \param model_data_file[in]: the path of model data file +/// \param input_nodes[in]: the array of input nodes' name +/// \param output_nodes[in]: the array of output nodes' name +/// \param device_type[in]: one of [CPU, GPU, HEXAGON], +/// based on the runtime type of your model deployment file. +/// \param engine[out]: output MaceEngine object +/// \return MACE_SUCCESS for success, MACE_INVALID_ARGS for wrong arguments, +/// MACE_OUT_OF_RESOURCES for resources is out of range. __attribute__((visibility("default"))) MaceStatus CreateMaceEngineFromProto( const std::vector &model_pb, diff --git a/mace/python/tools/mace_engine_factory.h.jinja2 b/mace/python/tools/mace_engine_factory.h.jinja2 index e1a81753f23d33c54a13fc45134be4b7145406cd..472879365035bfe8a9ac945766dd559e94d72bf4 100644 --- a/mace/python/tools/mace_engine_factory.h.jinja2 +++ b/mace/python/tools/mace_engine_factory.h.jinja2 @@ -47,6 +47,21 @@ std::map model_name_map { }; } // namespace +/// \brief Create MaceEngine from code +/// +/// Create MaceEngine object based on model graph code and model data file or +/// model data code. +/// +/// \param model_name[in]: the name of model you want to use. +/// \param model_data_file[in]: the path of model data file, +/// if model_data_format is code, just pass empty string("") +/// \param input_nodes[in]: the array of input nodes' name +/// \param output_nodes[in]: the array of output nodes' name +/// \param device_type[in]: one of [CPU, GPU, HEXAGON], +/// based on the runtime type of your model deployment file. +/// \param engine[out]: output MaceEngine object +/// \return MACE_SUCCESS for success, MACE_INVALID_ARGS for wrong arguments, +/// MACE_OUT_OF_RESOURCES for resources is out of range. MaceStatus CreateMaceEngineFromCode( const std::string &model_name, const std::string &model_data_file,