MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / print

Method print

src/core/ITensor.cpp:73–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71
72#ifdef ARM_COMPUTE_ASSERTS_ENABLED
73void ITensor::print(std::ostream &s, IOFormatInfo io_fmt) const
74{
75 ARM_COMPUTE_ERROR_ON(this->buffer() == nullptr);
76
77 const DataType dt = this->info()->data_type();
78 const size_t slices2D = this->info()->tensor_shape().total_size_upper(2);
79 const Strides strides = this->info()->strides_in_bytes();
80 const PaddingSize padding = this->info()->padding();
81 const size_t num_channels = this->info()->num_channels();
82 std::ios stream_status(nullptr);
83 stream_status.copyfmt(s);
84
85 // Set precision
86 if (is_data_type_float(dt) && (io_fmt.precision_type != IOFormatInfo::PrecisionType::Default))
87 {
88 int precision = io_fmt.precision;
89 if (io_fmt.precision_type == IOFormatInfo::PrecisionType::Full)
90 {
91 precision = std::numeric_limits<float>().max_digits10;
92 }
93 s.precision(precision);
94 }
95
96 // Define region to print
97 size_t print_width = 0;
98 size_t print_height = 0;
99 int start_offset = 0;
100 switch (io_fmt.print_region)
101 {
102 case IOFormatInfo::PrintRegion::NoPadding:
103 print_width = this->info()->dimension(0);
104 print_height = this->info()->dimension(1);
105 start_offset = this->info()->offset_first_element_in_bytes();
106 break;
107 case IOFormatInfo::PrintRegion::ValidRegion:
108 print_width = this->info()->valid_region().shape.x();
109 print_height = this->info()->valid_region().shape.y();
110 start_offset = this->info()->offset_element_in_bytes(
111 Coordinates(this->info()->valid_region().anchor.x(), this->info()->valid_region().anchor.y()));
112 break;
113 case IOFormatInfo::PrintRegion::Full:
114 print_width = padding.left + this->info()->dimension(0) + padding.right;
115 print_height = padding.top + this->info()->dimension(1) + padding.bottom;
116 start_offset = static_cast<int>(this->info()->offset_first_element_in_bytes()) - padding.top * strides[1] -
117 padding.left * strides[0];
118 break;
119 default:
120 break;
121 }
122
123 print_width = print_width * num_channels;
124
125 // Set pointer to start
126 const uint8_t *ptr = this->buffer() + start_offset;
127
128 // Start printing
129 for (size_t i = 0; i < slices2D; ++i)
130 {

Callers 6

access_tensorMethod · 0.45
print_allMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
do_teardownMethod · 0.45
mainFunction · 0.45

Calls 15

is_data_type_floatFunction · 0.85
total_size_upperMethod · 0.80
CoordinatesClass · 0.50
bufferMethod · 0.45
data_typeMethod · 0.45
infoMethod · 0.45
paddingMethod · 0.45
num_channelsMethod · 0.45
dimensionMethod · 0.45

Tested by

no test coverage detected