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

Method print

source/core/Tensor.cpp:344–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342 }
343}
344void Tensor::print() const {
345 // print dimensions
346 MNN_PRINT("====== Tensor %p ======", this);
347 MNN_PRINT("\nDimension: ");
348 for (int i = 0; i < mBuffer.dimensions; i++) {
349 MNN_PRINT("%d, ", mBuffer.dim[i].extent);
350 }
351
352 // convert to host if needed
353 auto printee = this;
354 auto bnType = MNN_FORWARD_CPU;
355 if (nullptr != mDescribe->getBackend()) {
356 bnType = mDescribe->getBackend()->type();
357 }
358 bool device = bnType != MNN_FORWARD_CPU;
359 if (device) {
360 printee = this->createHostTensorFromDevice(this, true);
361 }
362 auto buffer = printee->buffer().host;
363
364 MNN_PRINT("\nData: ");
365 if (printee->getType().code == halide_type_int) {
366 if (printee->getType().bits == 8) { // int8
367 printData<int8_t>(printee, buffer, "%d, ");
368 } else if (printee->getType().bits == 16) { // int16
369 printData<int16_t>(printee, buffer, "%d, ");
370 } else if (printee->getType().bits == 32) { // int32
371 printData<int32_t>(printee, buffer, "%d, ");
372 } else {
373 MNN_PRINT("\nunsupported data type");
374 }
375 } else if (printee->getType().code == halide_type_uint) {
376 if (printee->getType().bits == 8) { // uint8
377 printData<uint8_t>(printee, buffer, "%d, ");
378 } else {
379 MNN_PRINT("\nunsupported data type");
380 }
381 } else if (printee->getType().code == halide_type_float) {
382 if (printee->getType().bits == 32) { // float32
383 printData<float>(printee, buffer, "%f, ");
384 } else {
385 MNN_PRINT("\nunsupported data type\n");
386 }
387 } else {
388 MNN_PRINT("\nunsupported data type");
389 }
390
391 // clean up
392 if (printee != this) {
393 delete printee;
394 }
395}
396
397void Tensor::printShape() const {
398 const int dims = this->dimensions();

Callers 15

_fake_quant_weightMethod · 0.45
_fake_quant_featureMethod · 0.45
initMethod · 0.45
return_average_scaleMethod · 0.45
_prune_weightMethod · 0.45
__init__Method · 0.45
_prune_weightMethod · 0.45
bodyMethod · 0.45

Calls 5

getBackendMethod · 0.45
typeMethod · 0.45
bufferMethod · 0.45
getTypeMethod · 0.45

Tested by 1

printFunction · 0.36