MCPcopy Create free account
hub / github.com/OpenPPL/ppl.nn / PrintInputOutputInfo

Function PrintInputOutputInfo

samples/cpp/api/api_intro.cc:57–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57static void PrintInputOutputInfo(const Runtime* runtime) {
58 cout << "----- input info -----" << endl;
59 for (uint32_t i = 0; i < runtime->GetInputCount(); ++i) {
60 auto tensor = runtime->GetInputTensor(i);
61 cout << "input[" << i << "]:" << endl << " name: " << tensor->GetName() << endl;
62
63 string dims_str;
64 auto& shape = *tensor->GetShape();
65 for (uint32_t j = 0; j < shape.GetDimCount(); ++j) {
66 dims_str += " " + std::to_string(shape.GetDim(j));
67 }
68 cout << " dim(s):" << dims_str << endl
69 << " DataType: " << GetDataTypeStr(shape.GetDataType()) << endl
70 << " DataFormat: " << GetDataFormatStr(shape.GetDataFormat()) << endl
71 << " BytesIncludePadding: " << shape.CalcBytesIncludingPadding() << endl
72 << " BytesExcludePadding: " << shape.CalcBytesExcludingPadding() << endl;
73 }
74
75 cout << "----- output info -----" << endl;
76 for (uint32_t i = 0; i < runtime->GetOutputCount(); ++i) {
77 auto tensor = runtime->GetOutputTensor(i);
78 cout << "output[" << i << "]:" << endl << " name: " << tensor->GetName();
79
80 string dims_str;
81 auto& shape = *tensor->GetShape();
82 for (uint32_t j = 0; j < shape.GetDimCount(); ++j) {
83 dims_str += " " + std::to_string(shape.GetDim(j));
84 }
85 cout << " dim(s):" << dims_str << endl
86 << " DataType: " << GetDataTypeStr(shape.GetDataType()) << endl
87 << " DataFormat: " << GetDataFormatStr(shape.GetDataFormat()) << endl
88 << " BytesIncludePadding: " << shape.CalcBytesIncludingPadding() << endl
89 << " BytesExcludePadding: " << shape.CalcBytesExcludingPadding() << endl;
90 }
91
92 cout << "----------------------" << endl;
93}
94
95int main(void) {
96 const char* model_file = "tests/testdata/conv.onnx";

Callers 1

mainFunction · 0.70

Calls 6

GetInputTensorMethod · 0.80
GetOutputTensorMethod · 0.80
GetInputCountMethod · 0.45
GetNameMethod · 0.45
GetShapeMethod · 0.45
GetOutputCountMethod · 0.45

Tested by

no test coverage detected