| 2083 | } |
| 2084 | |
| 2085 | void ShuffleDims(const Shape& input_shape, AxesOrder input_axes_order, |
| 2086 | AxesOrder output_axes_order, Shape* output_shape) { |
| 2087 | if (input_axes_order == AxesOrder::kHWIM && |
| 2088 | output_axes_order == AxesOrder::k1HWO) { |
| 2089 | // This special case isn't just a permutation, the IM pair of dims get |
| 2090 | // merged into the 3 dim, so we have to special-case it. |
| 2091 | *output_shape = Shape({1, input_shape.dims(0), input_shape.dims(1), |
| 2092 | input_shape.dims(3) * input_shape.dims(2)}); |
| 2093 | } else { |
| 2094 | std::vector<int> shuffle; |
| 2095 | GetShuffleShape(input_axes_order, output_axes_order, &shuffle); |
| 2096 | std::vector<int>* output_dims = output_shape->mutable_dims(); |
| 2097 | output_dims->resize(input_shape.dimensions_count()); |
| 2098 | for (int i = 0; i < input_shape.dimensions_count(); i++) { |
| 2099 | (*output_dims)[i] = input_shape.dims(shuffle[i]); |
| 2100 | } |
| 2101 | } |
| 2102 | } |
| 2103 | |
| 2104 | template <typename T> |
| 2105 | void ShuffleArrayTemplate(const Shape& input_shape, AxesOrder input_axes_order, |
no test coverage detected