#ifndef THIRD_PARTY_TENSORFLOW_CORE_KERNELS_TRANSPOSE_OP_FUNCTOR_H_ #define THIRD_PARTY_TENSORFLOW_CORE_KERNELS_TRANSPOSE_OP_FUNCTOR_H_ #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" #include "tensorflow/core/framework/tensor_types.h" namespace tensorflow { namespace functor { template void Transpose(const Device& d, typename TTypes::Tensor out, typename TTypes::ConstTensor in, const int* perm) { // perm[] is a permutation of 0, 1, ..., NDIMS-1. perm[] is on CPU. Eigen::array p; for (int i = 0; i < NDIMS; ++i) p[i] = perm[i]; out.device(d) = in.shuffle(p); } template struct TransposeFunctor { void operator()(const Device& d, typename TTypes::Tensor out, typename TTypes::ConstTensor in, const int* perm); }; } // namespace functor } // namespace tensorflow #endif // THIRD_PARTY_TENSORFLOW_CORE_KERNELS_TRANSPOSE_OP_FUNCTOR_H_