From 7aba2972c651c831c6cea4512129354c6f0803c2 Mon Sep 17 00:00:00 2001 From: liuqi Date: Fri, 3 Aug 2018 16:13:04 +0800 Subject: [PATCH] Add comments for some APIs. --- mace/examples/cli/example.cc | 6 ++++-- mace/public/mace.h | 13 +++++++++++++ mace/python/tools/mace_engine_factory.h.jinja2 | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/mace/examples/cli/example.cc b/mace/examples/cli/example.cc index ec93674e..4892baf2 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 9a35da5b..f6116348 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 e1a81753..47287936 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, -- GitLab