| 321 | // transposing is not necessary. |
| 322 | template <typename Device, typename T> |
| 323 | Status TransposeOperand(OpKernelContext* ctx, const Tensor& input, |
| 324 | const std::vector<int>& permutation, Tensor* output) { |
| 325 | if (!ShouldTranspose(input.shape(), permutation)) { |
| 326 | return CopyFrom(input, input.shape(), output); |
| 327 | } |
| 328 | TensorShape transposed_shape; |
| 329 | for (int i = 0; i < input.dims(); ++i) { |
| 330 | transposed_shape.AddDim(input.dim_size(permutation[i])); |
| 331 | } |
| 332 | TF_RETURN_IF_ERROR( |
| 333 | ctx->allocate_temp(DataTypeToEnum<T>::value, transposed_shape, output)); |
| 334 | const Device& device = ctx->eigen_device<Device>(); |
| 335 | TF_RETURN_IF_ERROR(DoTranspose(device, input, permutation, output)); |
| 336 | return Status::OK(); |
| 337 | } |
| 338 | |
| 339 | // If there are repeated labels in either the input or output, then this strides |
| 340 | // the input (e.g. iii->i) or inflates it (e.g. i->iii), respectively. |
nothing calls this directly
no test coverage detected