MCPcopy Create free account
hub / github.com/JDAI-CV/DNNLibrary / GetModel

Function GetModel

binaries/dnn_benchmark.cpp:41–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41auto GetModel(css &daqName, const bool allow_fp16,
42 const int compile_preference) {
43 std::unique_ptr<Model> model;
44 ModelBuilder builder;
45 if (hasEnding(daqName, ".daq")) {
46 DaqReader daq_reader;
47 // Set the last argument to true to use mmap. It may be more efficient
48 // than memory buffer.
49 daq_reader.ReadDaq(daqName, builder, false);
50#ifdef DNN_READ_ONNX
51 } else if (hasEnding(daqName, ".onnx")) {
52 OnnxReader onnx_reader;
53 // Set the last argument to true to use mmap. It may be more efficient
54 // than memory buffer.
55 onnx_reader.ReadOnnx(daqName, builder);
56#endif
57 } else {
58 throw std::invalid_argument(
59 "Wrong model name " + daqName +
60 ". It must end with .daq or .onnx (.onnx is only "
61 "supported when DNN_READ_ONNX is ON)");
62 }
63 model = builder.AllowFp16(allow_fp16).Compile(compile_preference);
64 return model;
65}
66
67auto PrefCodeToStr(const int &preference_code) {
68 if (preference_code == ANEURALNETWORKS_PREFER_FAST_SINGLE_ANSWER) {

Callers 2

mainFunction · 0.70
ReadDaqImplFunction · 0.50

Calls 4

ReadDaqMethod · 0.80
ReadOnnxMethod · 0.80
CompileMethod · 0.80
hasEndingFunction · 0.70

Tested by

no test coverage detected