44 RawTensor tensor(std::move(SimpleTensor<T>(input)));
46 TensorInfo
info(tensor.shape(), tensor.num_channels(), tensor.data_type());
49 const size_t slices2D =
info.tensor_shape().total_size_upper(2);
50 const Strides strides =
info.strides_in_bytes();
52 const size_t num_channels =
info.num_channels();
54 std::ostringstream os;
59 int precision = io_fmt.precision;
62 precision = std::numeric_limits<float>().max_digits10;
64 os.precision(precision);
68 size_t print_width = 0;
69 size_t print_height = 0;
71 switch(io_fmt.print_region)
74 print_width =
info.dimension(0);
75 print_height =
info.dimension(1);
76 start_offset =
info.offset_first_element_in_bytes();
79 print_width =
info.valid_region().shape.x();
80 print_height =
info.valid_region().shape.y();
81 start_offset =
info.offset_element_in_bytes(Coordinates(
info.valid_region().anchor.x(),
82 info.valid_region().anchor.y()));
85 print_width = padding.left +
info.dimension(0) + padding.right;
86 print_height = padding.top +
info.dimension(1) + padding.bottom;
87 start_offset =
static_cast<int>(
info.offset_first_element_in_bytes()) - padding.top * strides[1] - padding.left * strides[0];
93 print_width = print_width * num_channels;
96 const uint8_t *ptr = tensor.data() + start_offset;
99 for(
size_t i = 0; i < slices2D; ++i)
102 int max_element_width = 0;
103 if(io_fmt.align_columns)
105 size_t offset = i * strides[2];
106 for(
size_t h = 0; h < print_height; ++h)
108 max_element_width = std::max<int>(max_element_width, max_consecutive_elements_display_width(os, dt, ptr + offset, print_width));
109 offset += strides[1];
115 size_t offset = i * strides[2];
116 for(
size_t h = 0; h < print_height; ++h)
118 print_consecutive_elements(os, dt, ptr + offset, print_width, max_element_width, io_fmt.element_delim);
119 offset += strides[1];
120 os << io_fmt.row_delim;
122 os << io_fmt.row_delim;
129 template <
typename T>
130 inline std::ostream &operator<<(std::ostream &os, const SimpleTensor<T> &tensor)
136 template <
typename T>
137 inline std::string
to_string(
const SimpleTensor<T> &tensor)
139 std::stringstream
ss;
144 #if PRINT_TENSOR_LIMIT 145 template <
typename T>
148 if(tensor.num_elements() < PRINT_TENSOR_LIMIT)
150 std::cout << title <<
":" << std::endl;
151 std::cout << prettify_tensor(tensor, IOFormatInfo{ region });
154 #endif // PRINT_TENSOR_LIMIT __global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
std::stringstream ss(mlgo_str)
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Copyright (c) 2017-2021 Arm Limited.
std::string to_string(const ROIPoolingLayerInfo &pool_info)
Formatted output of the ROIPoolingInfo type.
BorderSize PaddingSize
Container for 2D padding size.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
DataType
Available data types.
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.