Accessor to remove the dimension n from the tensor shape. * * @note The upper dimensions of the tensor shape will be shifted down by 1 * * @param[in] n Dimension to remove * @param[in] apply_dim_correction (Optional) Flag to state whether apply dimension correction (removing trailing dimensions with size of 1) after removing a dimension. */
| 111 | * @param[in] apply_dim_correction (Optional) Flag to state whether apply dimension correction (removing trailing dimensions with size of 1) after removing a dimension. |
| 112 | */ |
| 113 | void remove_dimension(size_t n, bool apply_dim_correction = true) |
| 114 | { |
| 115 | ARM_COMPUTE_ERROR_ON(_num_dimensions < 1); |
| 116 | ARM_COMPUTE_ERROR_ON(n >= _num_dimensions); |
| 117 | |
| 118 | std::copy(_id.begin() + n + 1, _id.end(), _id.begin() + n); |
| 119 | |
| 120 | // Reduce number of dimensions |
| 121 | _num_dimensions--; |
| 122 | |
| 123 | // Make sure all empty dimensions are filled with 1 |
| 124 | std::fill(_id.begin() + _num_dimensions, _id.end(), 1); |
| 125 | |
| 126 | // Correct number dimensions to ignore trailing dimensions of size 1 |
| 127 | if (apply_dim_correction) |
| 128 | { |
| 129 | apply_dimension_correction(); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | /** Collapse the first n dimensions. |
| 134 | * |
no test coverage detected