25 #ifndef ARM_COMPUTE_TEST_SIMPLE_TENSOR_PRINTER
26 #define ARM_COMPUTE_TEST_SIMPLE_TENSOR_PRINTER
45 RawTensor
tensor(std::move(SimpleTensor<T>(
input)));
50 const size_t slices2D =
info.tensor_shape().total_size_upper(2);
53 const size_t num_channels =
info.num_channels();
55 std::ostringstream os;
60 int precision = io_fmt.precision;
63 precision = std::numeric_limits<float>().max_digits10;
65 os.precision(precision);
69 size_t print_width = 0;
70 size_t print_height = 0;
72 switch(io_fmt.print_region)
75 print_width =
info.dimension(0);
76 print_height =
info.dimension(1);
77 start_offset =
info.offset_first_element_in_bytes();
80 print_width =
info.valid_region().shape.x();
81 print_height =
info.valid_region().shape.y();
82 start_offset =
info.offset_element_in_bytes(Coordinates(
info.valid_region().anchor.x(),
83 info.valid_region().anchor.y()));
86 print_width = padding.
left +
info.dimension(0) + padding.
right;
87 print_height = padding.
top +
info.dimension(1) + padding.
bottom;
88 start_offset =
static_cast<int>(
info.offset_first_element_in_bytes()) - padding.
top * strides[1] - padding.
left * strides[0];
94 print_width = print_width * num_channels;
97 const uint8_t *ptr =
tensor.data() + start_offset;
100 for(
size_t i = 0; i < slices2D; ++i)
103 int max_element_width = 0;
104 if(io_fmt.align_columns)
106 size_t offset = i * strides[2];
107 for(
size_t h = 0; h < print_height; ++h)
109 max_element_width = std::max<int>(max_element_width, max_consecutive_elements_display_width(os,
dt, ptr +
offset, print_width));
116 size_t offset = i * strides[2];
117 for(
size_t h = 0; h < print_height; ++h)
119 print_consecutive_elements(os,
dt, ptr +
offset, print_width, max_element_width, io_fmt.element_delim);
121 os << io_fmt.row_delim;
123 os << io_fmt.row_delim;
130 template <
typename T>
137 template <
typename T>
140 std::stringstream
ss;
145 #if PRINT_TENSOR_LIMIT
146 template <
typename T>
149 if(
tensor.num_elements() < PRINT_TENSOR_LIMIT)
151 std::cout << title <<
":" << std::endl;
155 #endif // PRINT_TENSOR_LIMIT