From eaf96c4533f9b3f8b0f6eac74e504ea00681a94b Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 24 Jan 2017 15:43:32 -0800 Subject: [PATCH] Increase maximum tensor rank to 7 for slice, strided_slice, and tile ops. Change: 145477962 --- tensorflow/contrib/makefile/tf_op_files.txt | 3 +++ tensorflow/core/kernels/BUILD | 4 ++++ tensorflow/core/kernels/slice_op.cc | 10 +++++--- .../core/kernels/slice_op_cpu_impl_7.cc | 18 +++++++++++++++ tensorflow/core/kernels/slice_op_gpu.cu.cc | 3 ++- tensorflow/core/kernels/strided_slice_op.cc | 3 +++ .../core/kernels/strided_slice_op_gpu.cu.cc | 3 +++ .../core/kernels/strided_slice_op_inst_7.cc | 23 +++++++++++++++++++ tensorflow/core/kernels/tile_ops.cc | 12 ++++++---- .../core/kernels/tile_ops_cpu_impl_7.cc | 18 +++++++++++++++ 10 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 tensorflow/core/kernels/slice_op_cpu_impl_7.cc create mode 100644 tensorflow/core/kernels/strided_slice_op_inst_7.cc create mode 100644 tensorflow/core/kernels/tile_ops_cpu_impl_7.cc diff --git a/tensorflow/contrib/makefile/tf_op_files.txt b/tensorflow/contrib/makefile/tf_op_files.txt index 85f5149600d..a83587904e7 100644 --- a/tensorflow/contrib/makefile/tf_op_files.txt +++ b/tensorflow/contrib/makefile/tf_op_files.txt @@ -13,8 +13,10 @@ tensorflow/core/kernels/tile_ops_cpu_impl_3.cc tensorflow/core/kernels/tile_ops_cpu_impl_4.cc tensorflow/core/kernels/tile_ops_cpu_impl_5.cc tensorflow/core/kernels/tile_ops_cpu_impl_6.cc +tensorflow/core/kernels/tile_ops_cpu_impl_7.cc tensorflow/core/kernels/tensor_array_ops.cc tensorflow/core/kernels/tensor_array.cc +tensorflow/core/kernels/strided_slice_op_inst_7.cc tensorflow/core/kernels/strided_slice_op_inst_6.cc tensorflow/core/kernels/strided_slice_op_inst_5.cc tensorflow/core/kernels/strided_slice_op_inst_4.cc @@ -38,6 +40,7 @@ tensorflow/core/kernels/slice_op_cpu_impl_3.cc tensorflow/core/kernels/slice_op_cpu_impl_4.cc tensorflow/core/kernels/slice_op_cpu_impl_5.cc tensorflow/core/kernels/slice_op_cpu_impl_6.cc +tensorflow/core/kernels/slice_op_cpu_impl_7.cc tensorflow/core/kernels/slice_op.cc tensorflow/core/kernels/shape_ops.cc tensorflow/core/kernels/session_ops.cc diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD index 10cd3e49593..a69b612592f 100644 --- a/tensorflow/core/kernels/BUILD +++ b/tensorflow/core/kernels/BUILD @@ -83,6 +83,7 @@ tf_kernel_library( "strided_slice_op_inst_4.cc", "strided_slice_op_inst_5.cc", "strided_slice_op_inst_6.cc", + "strided_slice_op_inst_7.cc", ], hdrs = [ "dense_update_ops.h", @@ -3481,6 +3482,7 @@ filegroup( "slice_op_cpu_impl_4.cc", "slice_op_cpu_impl_5.cc", "slice_op_cpu_impl_6.cc", + "slice_op_cpu_impl_7.cc", "softmax_op.cc", "softmax_op.h", "softmax_op_functor.h", @@ -3498,6 +3500,7 @@ filegroup( "strided_slice_op_inst_4.cc", "strided_slice_op_inst_5.cc", "strided_slice_op_inst_6.cc", + "strided_slice_op_inst_7.cc", "unpack_op.cc", "variable_ops.cc", "variable_ops.h", @@ -3683,6 +3686,7 @@ filegroup( "tile_ops_cpu_impl_4.cc", "tile_ops_cpu_impl_5.cc", "tile_ops_cpu_impl_6.cc", + "tile_ops_cpu_impl_7.cc", "topk_op.cc", "training_ops.cc", "transpose_functor_cpu.cc", diff --git a/tensorflow/core/kernels/slice_op.cc b/tensorflow/core/kernels/slice_op.cc index 575f61c9416..2a9ff40f8ca 100644 --- a/tensorflow/core/kernels/slice_op.cc +++ b/tensorflow/core/kernels/slice_op.cc @@ -179,6 +179,7 @@ class SliceOp : public OpKernel { HANDLE_DIM(4); HANDLE_DIM(5); HANDLE_DIM(6); + HANDLE_DIM(7); #undef HANDLE_DIM @@ -222,7 +223,8 @@ namespace functor { DECLARE_CPU_SPEC(T, 3); \ DECLARE_CPU_SPEC(T, 4); \ DECLARE_CPU_SPEC(T, 5); \ - DECLARE_CPU_SPEC(T, 6); + DECLARE_CPU_SPEC(T, 6); \ + DECLARE_CPU_SPEC(T, 7); TF_CALL_ALL_TYPES(DECLARE_FOR_N); DECLARE_FOR_N(bfloat16); @@ -263,7 +265,8 @@ namespace functor { DECLARE_GPU_SPEC(T, 3); \ DECLARE_GPU_SPEC(T, 4); \ DECLARE_GPU_SPEC(T, 5); \ - DECLARE_GPU_SPEC(T, 6); + DECLARE_GPU_SPEC(T, 6); \ + DECLARE_GPU_SPEC(T, 7); TF_CALL_GPU_NUMBER_TYPES(DECLARE_FOR_N); TF_CALL_complex64(DECLARE_FOR_N); @@ -322,7 +325,8 @@ namespace functor { DECLARE_SYCL_SPEC(T, 3); \ DECLARE_SYCL_SPEC(T, 4); \ DECLARE_SYCL_SPEC(T, 5); \ - DECLARE_SYCL_SPEC(T, 6); + DECLARE_SYCL_SPEC(T, 6); \ + DECLARE_SYCL_SPEC(T, 7); TF_CALL_GPU_NUMBER_TYPES(DECLARE_FOR_N); DECLARE_FOR_N(int32); diff --git a/tensorflow/core/kernels/slice_op_cpu_impl_7.cc b/tensorflow/core/kernels/slice_op_cpu_impl_7.cc new file mode 100644 index 00000000000..36f35d751a0 --- /dev/null +++ b/tensorflow/core/kernels/slice_op_cpu_impl_7.cc @@ -0,0 +1,18 @@ +/* Copyright 2017 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. +==============================================================================*/ + +#define CPU_PROVIDED_IXDIM 7 +#include "tensorflow/core/kernels/slice_op_cpu_impl.h" +#undef CPU_PROVIDED_IXDIM diff --git a/tensorflow/core/kernels/slice_op_gpu.cu.cc b/tensorflow/core/kernels/slice_op_gpu.cu.cc index 5590ae29056..a301986f2ff 100644 --- a/tensorflow/core/kernels/slice_op_gpu.cu.cc +++ b/tensorflow/core/kernels/slice_op_gpu.cu.cc @@ -33,7 +33,8 @@ typedef Eigen::GpuDevice GPUDevice; template struct functor::Slice; \ template struct functor::Slice; \ template struct functor::Slice; \ - template struct functor::Slice; + template struct functor::Slice; \ + template struct functor::Slice; TF_CALL_GPU_NUMBER_TYPES(DEFINE_GPU_KERNELS); TF_CALL_complex64(DEFINE_GPU_KERNELS); diff --git a/tensorflow/core/kernels/strided_slice_op.cc b/tensorflow/core/kernels/strided_slice_op.cc index 5cbdcab315d..a3738655098 100644 --- a/tensorflow/core/kernels/strided_slice_op.cc +++ b/tensorflow/core/kernels/strided_slice_op.cc @@ -162,6 +162,7 @@ class StridedSliceOp : public OpKernel { HANDLE_DIM(4); HANDLE_DIM(5); HANDLE_DIM(6); + HANDLE_DIM(7); #undef HANDLE_DIM @@ -261,6 +262,7 @@ class StridedSliceGradOp : public OpKernel { HANDLE_DIM(4); HANDLE_DIM(5); HANDLE_DIM(6); + HANDLE_DIM(7); #undef HANDLE_DIM } @@ -338,6 +340,7 @@ class StridedSliceAssignOp : public OpKernel { HANDLE_DIM(4); HANDLE_DIM(5); HANDLE_DIM(6); + HANDLE_DIM(7); #undef HANDLE_DIM OP_REQUIRES(context, false, diff --git a/tensorflow/core/kernels/strided_slice_op_gpu.cu.cc b/tensorflow/core/kernels/strided_slice_op_gpu.cu.cc index e8f75cf38d0..040f38ef5ac 100644 --- a/tensorflow/core/kernels/strided_slice_op_gpu.cu.cc +++ b/tensorflow/core/kernels/strided_slice_op_gpu.cu.cc @@ -34,18 +34,21 @@ typedef Eigen::GpuDevice GPUDevice; template struct functor::StridedSlice; \ template struct functor::StridedSlice; \ template struct functor::StridedSlice; \ + template struct functor::StridedSlice; \ template struct functor::StridedSliceGrad; \ template struct functor::StridedSliceGrad; \ template struct functor::StridedSliceGrad; \ template struct functor::StridedSliceGrad; \ template struct functor::StridedSliceGrad; \ template struct functor::StridedSliceGrad; \ + template struct functor::StridedSliceGrad; \ template struct functor::StridedSliceAssign; \ template struct functor::StridedSliceAssign; \ template struct functor::StridedSliceAssign; \ template struct functor::StridedSliceAssign; \ template struct functor::StridedSliceAssign; \ template struct functor::StridedSliceAssign; \ + template struct functor::StridedSliceAssign; \ template struct functor::StridedSliceAssignScalar; TF_CALL_GPU_NUMBER_TYPES(DEFINE_GPU_KERNELS); DEFINE_GPU_KERNELS(int32); diff --git a/tensorflow/core/kernels/strided_slice_op_inst_7.cc b/tensorflow/core/kernels/strided_slice_op_inst_7.cc new file mode 100644 index 00000000000..88b44cfbb18 --- /dev/null +++ b/tensorflow/core/kernels/strided_slice_op_inst_7.cc @@ -0,0 +1,23 @@ +/* Copyright 2017 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. +==============================================================================*/ + +#define EIGEN_USE_THREADS +#if GOOGLE_CUDA +#define EIGEN_USE_GPU +#endif + +#define STRIDED_SLICE_INSTANTIATE_DIM 7 +#include "tensorflow/core/kernels/strided_slice_op_impl.h" +#undef STRIDED_SLICE_INSTANTIATE_DIM diff --git a/tensorflow/core/kernels/tile_ops.cc b/tensorflow/core/kernels/tile_ops.cc index 36cabaaf7d3..e55c8679e92 100644 --- a/tensorflow/core/kernels/tile_ops.cc +++ b/tensorflow/core/kernels/tile_ops.cc @@ -142,7 +142,8 @@ class TileOp : public OpKernel { HANDLE_DIM(T, 3) \ HANDLE_DIM(T, 4) \ HANDLE_DIM(T, 5) \ - HANDLE_DIM(T, 6) + HANDLE_DIM(T, 6) \ + HANDLE_DIM(T, 7) #define HANDLE_TYPE_NAME(T) HANDLE_TYPE(DataTypeToEnum::value) @@ -220,7 +221,8 @@ inline void TileOp::HandleCase( HANDLE_CASE(device, T, dtype, 3); \ HANDLE_CASE(device, T, dtype, 4); \ HANDLE_CASE(device, T, dtype, 5); \ - HANDLE_CASE(device, T, dtype, 6); + HANDLE_CASE(device, T, dtype, 6); \ + HANDLE_CASE(device, T, dtype, 7); #define HANDLE_TYPE_NAME_CPU(T) \ HANDLE_CASE_DIM(CPUDevice, T, DataTypeToEnum::value); @@ -327,7 +329,8 @@ class TileGradientOp : public OpKernel { HANDLE_DIM(T, 3) \ HANDLE_DIM(T, 4) \ HANDLE_DIM(T, 5) \ - HANDLE_DIM(T, 6) + HANDLE_DIM(T, 6) \ + HANDLE_DIM(T, 7) #define HANDLE_TYPE_NAME(T) HANDLE_TYPE(DataTypeToEnum::value) @@ -474,7 +477,8 @@ inline void TileGradientOp::HandleCase( HANDLE_CASE(device, T, dtype, 3); \ HANDLE_CASE(device, T, dtype, 4); \ HANDLE_CASE(device, T, dtype, 5); \ - HANDLE_CASE(device, T, dtype, 6); + HANDLE_CASE(device, T, dtype, 6); \ + HANDLE_CASE(device, T, dtype, 7); #define HANDLE_TYPE_NAME_CPU(T) \ HANDLE_CASE_DIM(CPUDevice, T, DataTypeToEnum::value); diff --git a/tensorflow/core/kernels/tile_ops_cpu_impl_7.cc b/tensorflow/core/kernels/tile_ops_cpu_impl_7.cc new file mode 100644 index 00000000000..c3fccd945fe --- /dev/null +++ b/tensorflow/core/kernels/tile_ops_cpu_impl_7.cc @@ -0,0 +1,18 @@ +/* Copyright 2017 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. +==============================================================================*/ + +#define CPU_PROVIDED_IXDIM 7 +#include "tensorflow/core/kernels/tile_ops_cpu_impl.h" +#undef CPU_PROVIDED_IXDIM