| 94 | float constant_border_value); |
| 95 | |
| 96 | RawTensor transpose(const RawTensor &src, int chunk_width) |
| 97 | { |
| 98 | // Create reference |
| 99 | TensorShape dst_shape(src.shape()); |
| 100 | dst_shape.set(0, src.shape().y() * chunk_width); |
| 101 | dst_shape.set(1, std::ceil(src.shape().x() / static_cast<float>(chunk_width))); |
| 102 | |
| 103 | RawTensor dst{dst_shape, src.data_type()}; |
| 104 | |
| 105 | // Compute reference |
| 106 | uint8_t *out_ptr = dst.data(); |
| 107 | |
| 108 | for (int i = 0; i < dst.num_elements(); i += chunk_width) |
| 109 | { |
| 110 | Coordinates coord = index2coord(dst.shape(), i); |
| 111 | size_t coord_x = coord.x(); |
| 112 | coord.set(0, coord.y() * chunk_width); |
| 113 | coord.set(1, coord_x / chunk_width); |
| 114 | |
| 115 | const int num_elements = std::min<int>(chunk_width, src.shape().x() - coord.x()); |
| 116 | |
| 117 | std::copy_n(static_cast<const uint8_t *>(src(coord)), num_elements * src.element_size(), out_ptr); |
| 118 | |
| 119 | out_ptr += chunk_width * dst.element_size(); |
| 120 | } |
| 121 | |
| 122 | return dst; |
| 123 | } |
| 124 | |
| 125 | bool valid_bilinear_policy(float xn, float yn, int width, int height, BorderMode border_mode) |
| 126 | { |
no test coverage detected