MCPcopy Create free account
hub / github.com/MegEngine/MegCC / inference

Function inference

yolox_example/main.cpp:370–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368}
369
370std::vector<float> inference(const char* model_path, std::vector<float>& input_data) {
371 LITE_set_log_level(INFO);
372 LiteNetwork model;
373 LiteTensor input;
374 size_t input_length;
375 //! make network
376 LITE_CAPI_CHECK(
377 LITE_make_network(&model, *default_config(), *default_network_io()),
378 "create model error. \n");
379 LITE_CAPI_CHECK(
380 LITE_load_model_from_path(model, model_path), "load model error. \n");
381 //! set input tensor
382 LITE_CAPI_CHECK(
383 LITE_get_io_tensor(model, "data", LITE_INPUT, &input),
384 "get input tensor failed\n");
385 LITE_CAPI_CHECK(
386 LITE_get_tensor_total_size_in_byte(input, &input_length),
387 "get input tensor size failed\n");
388
389 LITE_CAPI_CHECK(
390 LITE_reset_tensor_memory(input, input_data.data(), input_length),
391 "set input ptr failed\n");
392
393 LITE_CAPI_CHECK(LITE_destroy_tensor(input), "destory input tensor");
394
395 std::vector<float> output = run_model(model);
396 LITE_CAPI_CHECK(LITE_destroy_network(model), "delete model failed\n");
397 return output;
398}
399
400std::string keys =
401 "{ @model | | the inference model path}"

Callers 1

mainFunction · 0.85

Calls 11

LITE_set_log_levelFunction · 0.85
LITE_make_networkFunction · 0.85
default_configFunction · 0.85
default_network_ioFunction · 0.85
LITE_get_io_tensorFunction · 0.85
LITE_reset_tensor_memoryFunction · 0.85
LITE_destroy_tensorFunction · 0.85
LITE_destroy_networkFunction · 0.85
run_modelFunction · 0.70

Tested by

no test coverage detected