#include <onnxruntime_cxx_api.h>
#include <iostream>
#include <cstdint>
Go to the source code of this file.
|
int | main (int narg, char *argv[]) |
|
◆ main()
int main |
( |
int |
narg, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 9 of file get-onnx-metadata.cxx.
10 if (narg != 3 && narg != 2) {
11 std::cout <<
"usage: " <<
argv[0] <<
" <onnx_file> [key]" << std::endl;
16 auto env = std::make_unique< Ort::Env >(ORT_LOGGING_LEVEL_ERROR,
"");
19 Ort::SessionOptions session_options;
20 session_options.SetIntraOpNumThreads(1);
21 session_options.SetGraphOptimizationLevel(
22 GraphOptimizationLevel::ORT_DISABLE_ALL);
25 auto session = std::make_unique< Ort::Session >(*
env,
argv[1],
29 Ort::AllocatorWithDefaultOptions allocator;
30 Ort::ModelMetadata
metadata = session->GetModelMetadata();
32 std::cout <<
"keys: ";
33 auto keys =
metadata.GetCustomMetadataMapKeysAllocated(allocator);
35 std::cout <<
keys[
i].get();
36 if (
i+1 <
keys.size()) std::cout <<
", ";
38 std::cout << std::endl;
41 auto val =
metadata.LookupCustomMetadataMapAllocated(
argv[2], allocator);
42 std::cout <<
val.get() << std::endl;