MCPcopy Create free account
hub / github.com/alibaba/MNN / _initTensorStatic

Function _initTensorStatic

tools/cpp/ExprDebug.hpp:276–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274 return std::make_pair(valid, data);
275}
276static void _initTensorStatic() {
277 MNN::TensorCallBackWithInfo beforeCallBack = [&](const std::vector<MNN::Tensor*>& ntensors, const MNN::OperatorInfo* info) {
278 auto opName = info->name();
279 if (info->type() == "Copy") {
280 return true;
281 }
282 for (int i = 0; i < ntensors.size(); ++i) {
283 auto ntensor = ntensors[i];
284 auto res = _countForTensorValid(ntensor);
285 if (!res.first) {
286 continue;
287 }
288 auto data = res.second;
289 MNN_PRINT("%s [Input] %s_%d, type:%d-%d, Max: %f, Min: %f, Avg: %f, [", info->type().c_str(), opName.c_str(), i, ntensor->getType().code, ntensor->getType().bits, std::get<0>(data), std::get<1>(data), std::get<2>(data));
290 for (int v=0; v<ntensor->dimensions(); ++v) {
291 MNN_PRINT("%d", ntensor->length(v));
292 if (v!=ntensor->dimensions()-1) {
293 MNN_PRINT(",");
294 }
295 }
296 MNN_PRINT("]\n");
297 }
298 return true;
299 };
300 MNN::TensorCallBackWithInfo callBack = [&](const std::vector<MNN::Tensor*>& ntensors, const MNN::OperatorInfo* info) {
301 auto opName = info->name();
302 if (info->type() == "Copy") {
303 return true;
304 }
305 for (int i = 0; i < ntensors.size(); ++i) {
306 auto ntensor = ntensors[i];
307 auto res = _countForTensorValid(ntensor);
308 if (!res.first) {
309 continue;
310 }
311 auto data = res.second;
312 MNN_PRINT("%s [Output] %s_%d, type:%d-%d, Max: %f, Min: %f, Avg: %f, [", info->type().c_str(), opName.c_str(), i, ntensor->getType().code, ntensor->getType().bits, std::get<0>(data), std::get<1>(data), std::get<2>(data));
313 for (int v=0; v<ntensor->dimensions(); ++v) {
314 MNN_PRINT("%d", ntensor->length(v));
315 if (v!=ntensor->dimensions()-1) {
316 MNN_PRINT(",");
317 }
318 }
319 MNN_PRINT("]\n");
320 }
321 return true;
322 };
323 MNN::Express::ExecutorScope::Current()->setCallBack(std::move(beforeCallBack), std::move(callBack));
324}

Callers 4

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
initRuntimeMethod · 0.85

Calls 9

_countForTensorValidFunction · 0.85
setCallBackMethod · 0.80
nameMethod · 0.45
typeMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45
getTypeMethod · 0.45
dimensionsMethod · 0.45
lengthMethod · 0.45

Tested by 2

mainFunction · 0.68
mainFunction · 0.68