clean-up unused functors
This commit is contained in:
parent
6e0893c79c
commit
f5ebab7d17
@ -25,32 +25,6 @@ limitations under the License.
|
||||
namespace tensorflow {
|
||||
namespace functor {
|
||||
|
||||
// TODO(yangke): revisit these operations and in particular, see if we can
|
||||
// combine all of them into just one operation without causing nvcc to
|
||||
// timeout.
|
||||
template <typename Device, typename T, int Dims, typename IndexType>
|
||||
struct ShuffleAndReverse {
|
||||
void operator()(const Device& d,
|
||||
typename TTypes<T, Dims, IndexType>::ConstTensor input,
|
||||
const Eigen::DSizes<IndexType, Dims>& order,
|
||||
const Eigen::array<bool, Dims>& reverse_dims,
|
||||
typename TTypes<T, Dims, IndexType>::Tensor output) {
|
||||
output.device(d) = input.shuffle(order).reverse(reverse_dims);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Device, typename T, int Dims, typename IndexType>
|
||||
struct InflatePadAndShuffle {
|
||||
void operator()(
|
||||
const Device& d, typename TTypes<T, Dims, IndexType>::ConstTensor input,
|
||||
const Eigen::DSizes<IndexType, Dims>& strides,
|
||||
const Eigen::array<Eigen::IndexPair<IndexType>, Dims>& pad_dims,
|
||||
const Eigen::DSizes<IndexType, Dims>& order,
|
||||
typename TTypes<T, Dims, IndexType>::Tensor output) {
|
||||
output.device(d) = input.inflate(strides).pad(pad_dims).shuffle(order);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Device, typename Input, typename Filter, typename Output,
|
||||
typename OutputKernel>
|
||||
void SpatialConvolutionFunc(const Device& d, Output output, Input input,
|
||||
@ -199,60 +173,6 @@ struct TransformFilter {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Device, typename T, typename IndexType>
|
||||
struct TransformDepth {
|
||||
void operator()(const Device& d,
|
||||
typename TTypes<T, 4, IndexType>::ConstTensor in,
|
||||
const Eigen::DSizes<IndexType, 4>& shuffle,
|
||||
typename TTypes<T, 4, IndexType>::Tensor out) {
|
||||
Eigen::DSizes<IndexType, 3> merged_dims;
|
||||
Eigen::DSizes<IndexType, 4> expanded_dims;
|
||||
Eigen::DSizes<IndexType, 3> new_shuffle;
|
||||
|
||||
// Merge dimensions that won't be shuffled together to speed things up.
|
||||
if (shuffle[1] == 2 && shuffle[2] == 3) {
|
||||
merged_dims[0] = in.dimension(0);
|
||||
merged_dims[1] = in.dimension(1);
|
||||
merged_dims[2] = in.dimension(2) * in.dimension(3);
|
||||
new_shuffle[0] = shuffle[0];
|
||||
new_shuffle[1] = 2;
|
||||
new_shuffle[2] = shuffle[3];
|
||||
expanded_dims[0] = in.dimension(shuffle[0]);
|
||||
expanded_dims[1] = in.dimension(2);
|
||||
expanded_dims[2] = in.dimension(3);
|
||||
expanded_dims[3] = in.dimension(shuffle[3]);
|
||||
} else if (shuffle[0] == 2 && shuffle[1] == 3) {
|
||||
merged_dims[0] = in.dimension(0);
|
||||
merged_dims[1] = in.dimension(1);
|
||||
merged_dims[2] = in.dimension(2) * in.dimension(3);
|
||||
new_shuffle[0] = 2;
|
||||
new_shuffle[1] = shuffle[2];
|
||||
new_shuffle[2] = shuffle[3];
|
||||
expanded_dims[0] = in.dimension(2);
|
||||
expanded_dims[1] = in.dimension(3);
|
||||
expanded_dims[2] = in.dimension(shuffle[2]);
|
||||
expanded_dims[3] = in.dimension(shuffle[3]);
|
||||
} else if (shuffle[0] == 0 && shuffle[1] == 3 && shuffle[2] == 1 &&
|
||||
shuffle[3] == 2) {
|
||||
merged_dims[0] = in.dimension(0);
|
||||
merged_dims[1] = in.dimension(1) * in.dimension(2);
|
||||
merged_dims[2] = in.dimension(3);
|
||||
new_shuffle[0] = 0;
|
||||
new_shuffle[1] = 2;
|
||||
new_shuffle[2] = 1;
|
||||
expanded_dims[0] = in.dimension(0);
|
||||
expanded_dims[1] = in.dimension(3);
|
||||
expanded_dims[2] = in.dimension(1);
|
||||
expanded_dims[3] = in.dimension(2);
|
||||
} else {
|
||||
assert(false && "unexpected shuffle");
|
||||
}
|
||||
|
||||
out.device(d) =
|
||||
in.reshape(merged_dims).shuffle(new_shuffle).reshape(expanded_dims);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Device, typename T, typename IndexType, int NDIMS>
|
||||
struct PadInput {
|
||||
void operator()(const Device& d,
|
||||
|
@ -29,12 +29,6 @@ namespace tensorflow {
|
||||
|
||||
namespace functor {
|
||||
|
||||
template struct ShuffleAndReverse<Eigen::GpuDevice, float, 4, int>;
|
||||
template struct ShuffleAndReverse<Eigen::GpuDevice, float, 4,
|
||||
Eigen::DenseIndex>;
|
||||
|
||||
template struct TransformDepth<Eigen::GpuDevice, float, int>;
|
||||
|
||||
template struct SwapDimension1And2InTensor3<Eigen::GpuDevice, float4>;
|
||||
template struct SwapDimension1And2InTensor3<Eigen::GpuDevice, float2,
|
||||
/*conjugate=*/true>;
|
||||
|
@ -29,12 +29,6 @@ namespace tensorflow {
|
||||
|
||||
namespace functor {
|
||||
|
||||
template struct ShuffleAndReverse<Eigen::GpuDevice, Eigen::half, 4, int>;
|
||||
template struct ShuffleAndReverse<Eigen::GpuDevice, Eigen::half, 4,
|
||||
Eigen::DenseIndex>;
|
||||
|
||||
template struct TransformDepth<Eigen::GpuDevice, Eigen::half, int>;
|
||||
|
||||
template struct SwapDimension1And2InTensor3<Eigen::GpuDevice, Eigen::half>;
|
||||
|
||||
// For 2d ops.
|
||||
|
@ -1085,21 +1085,6 @@ void LaunchConv2DBackpropFilterOp<Eigen::GpuDevice, T>::operator()(
|
||||
// Forward declarations of the functor specializations for GPU.
|
||||
namespace functor {
|
||||
#define DECLARE_GPU_SPEC(T) \
|
||||
template <> \
|
||||
void ShuffleAndReverse<GPUDevice, T, 4, int>::operator()( \
|
||||
const GPUDevice& d, typename TTypes<T, 4, int>::ConstTensor input, \
|
||||
const Eigen::DSizes<int, 4>& order, \
|
||||
const Eigen::array<bool, 4>& reverse_dims, \
|
||||
typename TTypes<T, 4, int>::Tensor output); \
|
||||
extern template struct ShuffleAndReverse<GPUDevice, T, 4, int>; \
|
||||
template <> \
|
||||
void InflatePadAndShuffle<GPUDevice, T, 4, int>::operator()( \
|
||||
const GPUDevice& d, typename TTypes<T, 4, int>::ConstTensor input, \
|
||||
const Eigen::DSizes<int, 4>& strides, \
|
||||
const Eigen::array<Eigen::IndexPair<int>, 4>& pad_dims, \
|
||||
const Eigen::DSizes<int, 4>& order, \
|
||||
typename TTypes<T, 4, int>::Tensor output); \
|
||||
extern template struct InflatePadAndShuffle<GPUDevice, T, 4, int>; \
|
||||
template <> \
|
||||
void TransformFilter<GPUDevice, T, int, 4>::operator()( \
|
||||
const GPUDevice& d, FilterTensorFormat dst_filter_format, \
|
||||
@ -1107,12 +1092,6 @@ namespace functor {
|
||||
typename TTypes<T, 4, int>::Tensor out); \
|
||||
extern template struct TransformFilter<GPUDevice, T, int, 4>; \
|
||||
template <> \
|
||||
void TransformDepth<GPUDevice, T, int>::operator()( \
|
||||
const GPUDevice& d, typename TTypes<T, 4, int>::ConstTensor in, \
|
||||
const Eigen::DSizes<int, 4>& shuffle, \
|
||||
typename TTypes<T, 4, int>::Tensor out); \
|
||||
extern template struct TransformDepth<GPUDevice, T, int>; \
|
||||
template <> \
|
||||
void PadInput<GPUDevice, T, int, 4>::operator()( \
|
||||
const GPUDevice& d, typename TTypes<T, 4, int>::ConstTensor in, \
|
||||
const std::array<int, 2>& padding_left, \
|
||||
|
@ -1241,21 +1241,6 @@ void LaunchConv2DBackpropInputOp<GPUDevice, T>::operator()(
|
||||
// Forward declarations of the functor specializations for GPU.
|
||||
namespace functor {
|
||||
#define DECLARE_GPU_SPEC(T) \
|
||||
template <> \
|
||||
void ShuffleAndReverse<GPUDevice, T, 4, int>::operator()( \
|
||||
const GPUDevice& d, typename TTypes<T, 4, int>::ConstTensor input, \
|
||||
const Eigen::DSizes<int, 4>& order, \
|
||||
const Eigen::array<bool, 4>& reverse_dims, \
|
||||
typename TTypes<T, 4, int>::Tensor output); \
|
||||
extern template struct ShuffleAndReverse<GPUDevice, T, 4, int>; \
|
||||
template <> \
|
||||
void InflatePadAndShuffle<GPUDevice, T, 4, int>::operator()( \
|
||||
const GPUDevice& d, typename TTypes<T, 4, int>::ConstTensor input, \
|
||||
const Eigen::DSizes<int, 4>& strides, \
|
||||
const Eigen::array<Eigen::IndexPair<int>, 4>& pad_dims, \
|
||||
const Eigen::DSizes<int, 4>& order, \
|
||||
typename TTypes<T, 4, int>::Tensor output); \
|
||||
extern template struct InflatePadAndShuffle<GPUDevice, T, 4, int>; \
|
||||
template <> \
|
||||
void TransformFilter<GPUDevice, T, int, 4>::operator()( \
|
||||
const GPUDevice& d, FilterTensorFormat dst_filter_format, \
|
||||
@ -1263,12 +1248,6 @@ namespace functor {
|
||||
typename TTypes<T, 4, int>::Tensor out); \
|
||||
extern template struct TransformFilter<GPUDevice, T, int, 4>; \
|
||||
template <> \
|
||||
void TransformDepth<GPUDevice, T, int>::operator()( \
|
||||
const GPUDevice& d, typename TTypes<T, 4, int>::ConstTensor in, \
|
||||
const Eigen::DSizes<int, 4>& shuffle, \
|
||||
typename TTypes<T, 4, int>::Tensor out); \
|
||||
extern template struct TransformDepth<GPUDevice, T, int>; \
|
||||
template <> \
|
||||
void PadInput<GPUDevice, T, int, 4>::operator()( \
|
||||
const GPUDevice& d, typename TTypes<T, 4, int>::ConstTensor in, \
|
||||
const std::array<int, 2>& padding_left, \
|
||||
|
@ -1,39 +0,0 @@
|
||||
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
|
||||
|
||||
#define EIGEN_USE_GPU
|
||||
|
||||
#include "tensorflow/core/kernels/conv_2d.h"
|
||||
|
||||
#include "tensorflow/core/framework/register_types.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
typedef Eigen::GpuDevice GPUDevice;
|
||||
template struct functor::InflatePadAndShuffle<GPUDevice, double, 4, int>;
|
||||
template struct functor::InflatePadAndShuffle<GPUDevice, double, 4,
|
||||
Eigen::DenseIndex>;
|
||||
template struct functor::InflatePadAndShuffle<GPUDevice, float, 4, int>;
|
||||
template struct functor::InflatePadAndShuffle<GPUDevice, float, 4,
|
||||
Eigen::DenseIndex>;
|
||||
template struct functor::InflatePadAndShuffle<GPUDevice, Eigen::half, 4, int>;
|
||||
template struct functor::InflatePadAndShuffle<GPUDevice, Eigen::half, 4,
|
||||
Eigen::DenseIndex>;
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM
|
@ -133,19 +133,6 @@ TensorShape PoolParameters::forward_output_shape() {
|
||||
|
||||
#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
|
||||
|
||||
// Forward declarations of the functor specializations for GPU.
|
||||
namespace functor {
|
||||
#define DECLARE_GPU_SPEC(T) \
|
||||
template <> \
|
||||
void TransformDepth<GPUDevice, T, Eigen::DenseIndex>::operator()( \
|
||||
const GPUDevice& d, typename TTypes<T, 4>::ConstTensor in, \
|
||||
const Eigen::DSizes<Eigen::DenseIndex, 4>& shuffle, \
|
||||
typename TTypes<T, 4>::Tensor out); \
|
||||
extern template struct TransformDepth<GPUDevice, T, Eigen::DenseIndex>;
|
||||
|
||||
TF_CALL_GPU_NUMBER_TYPES(DECLARE_GPU_SPEC)
|
||||
#undef DECLARE_GPU_SPEC
|
||||
} // namespace functor
|
||||
|
||||
template <typename T>
|
||||
void DnnPoolingOp<T>::Compute(OpKernelContext* context,
|
||||
|
Loading…
Reference in New Issue
Block a user