13 #include <graph_status.h>
14 #include <model_runner.h>
22 const std::vector<TensorInfo>& infos,
32 std::vector<const TensorInfo*> inputInfos;
33 std::vector<const TensorInfo*> outputInfos;
38 inputInfos.push_back(&infos[0]);
39 outputInfos.push_back(&infos[1]);
50 inputInfos.push_back(&infos[0]);
51 inputInfos.push_back(&infos[1]);
52 outputInfos.push_back(&infos[2]);
55 for (
unsigned int i = 0; i < infos.size() - 1; ++i)
57 inputInfos.push_back(&infos[i]);
59 outputInfos.push_back(&infos.back());
62 outputInfos.push_back(&infos[0]);
66 inputInfos.push_back(&infos[0]);
67 outputInfos.push_back(&infos[1]);
68 inputInfos.push_back(&infos[2]);
70 auto conv2dDesc = PolymorphicDowncast<const Convolution2dDescriptor*>(&descriptor);
71 if(conv2dDesc->m_BiasEnabled)
73 inputInfos.push_back(&infos[3]);
79 inputInfos.push_back(&infos[0]);
80 outputInfos.push_back(&infos[1]);
81 inputInfos.push_back(&infos[2]);
83 auto conv2dDesc = PolymorphicDowncast<const DepthwiseConvolution2dDescriptor*>(&descriptor);
84 if(conv2dDesc->m_BiasEnabled)
86 inputInfos.push_back(&infos[3]);
92 inputInfos.push_back(&infos[0]);
93 outputInfos.push_back(&infos[1]);
94 inputInfos.push_back(&infos[2]);
95 auto fullyConnectedDesc = PolymorphicDowncast<const FullyConnectedDescriptor*>(&descriptor);
96 if(fullyConnectedDesc->m_BiasEnabled)
98 inputInfos.push_back(&infos[3]);
114 inputInfos.push_back(&infos[0]);
115 outputInfos.push_back(&infos[1]);
120 inputInfos.push_back(&infos[0]);
121 for (
unsigned int i = 1; i < infos.size(); ++i)
123 outputInfos.push_back(&infos[i]);
129 inputInfos.push_back(&infos[0]);
130 outputInfos.push_back(&infos[1]);
131 inputInfos.push_back(&infos[2]);
133 auto conv2dDesc = PolymorphicDowncast<const TransposeConvolution2dDescriptor*>(&descriptor);
134 if(conv2dDesc->m_BiasEnabled)
136 inputInfos.push_back(&infos[3]);
145 auto mappings =
GetTosaMapping(
nullptr, type, inputInfos, outputInfos, descriptor);
146 if (mappings->GetName() ==
"")
152 TosaSerializationHandler handler;
155 auto* block =
new TosaSerializationBasicBlock(
"main",
157 mappings->GetOperators(),
158 mappings->GetTensors(),
159 mappings->GetInputs(),
160 mappings->GetOutputs());
162 std::vector<TosaSerializationBasicBlock*> blocks;
163 blocks.emplace_back(block);
166 auto* region =
new TosaSerializationRegion(
"main", blocks);
167 handler.GetRegions().emplace_back(region);
170 TosaReference::IModelRunner runner;
172 #if !defined(TOSA_REFERENCE_MODEL_OUTPUT)
175 func_debug_t funcDebug;
177 FILE* file = fopen(
"/dev/null",
"w");
178 funcDebug.func_debug_file = (file ==
nullptr) ? stderr : file;
180 runner.setFuncDebug(funcDebug);
184 status = runner.initialize(handler);
186 #if !defined(TOSA_REFERENCE_MODEL_OUTPUT)
188 funcDebug.func_debug_file = stderr;
189 runner.setFuncDebug(funcDebug);
192 if(status == GraphStatus::TOSA_ERROR || status == GraphStatus::TOSA_UNPREDICTABLE)