1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #ifndef TENSORFLOW_CONTRIB_FUSED_CONV_KERNELS_FUSED_CONV2D_BIAS_ACTIVATION_OP_H_ 17 #define TENSORFLOW_CONTRIB_FUSED_CONV_KERNELS_FUSED_CONV2D_BIAS_ACTIVATION_OP_H_ 18 19 #include "tensorflow/core/framework/resource_mgr.h" 20 #include "tensorflow/core/framework/tensor_types.h" 21 #include "tensorflow/core/platform/mem.h" 22 #include "tensorflow/core/util/activation_mode.h" 23 #include "tensorflow/core/util/tensor_format.h" 24 25 #if GOOGLE_CUDA 26 #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" 27 #include "tensorflow/contrib/fused_conv/kernels/fused_conv_ops_gpu.h" 28 #include "tensorflow/core/platform/stream_executor.h" 29 #endif // GOOGLE_CUDA 30 31 namespace tensorflow { 32 33 // Forward declaration. 34 class OpKernelContext; 35 36 template <typename Device, typename T, typename BiasType, typename ScaleType> 37 class LaunchFusedConv2DBiasActivationOp { 38 public: 39 void launch(OpKernelContext* ctx, bool cudnn_use_autotune, 40 const Tensor& conv_input, ScaleType conv_input_scale, 41 const Tensor& filter, int32 row_stride, int32 col_stride, 42 const Eigen::PaddingType& padding, const Tensor& side_input, 43 ScaleType side_input_scale, const Tensor& bias, 44 ActivationMode activation_mode, TensorFormat data_format, 45 FilterTensorFormat filter_format, Tensor* output); 46 }; 47 48 #ifdef GOOGLE_CUDA 49 template <typename T, typename BiasType, typename ScaleType> 50 class LaunchFusedConv2DBiasActivationOp<Eigen::GpuDevice, T, BiasType, 51 ScaleType> { 52 public: 53 void launch(OpKernelContext* ctx, bool cudnn_use_autotune, 54 const Tensor& conv_input, ScaleType conv_input_scale, 55 const Tensor& filter, int32 row_stride, int32 col_stride, 56 const Eigen::PaddingType& padding, const Tensor& side_input, 57 ScaleType side_input_scale, const Tensor& bias, 58 ActivationMode activation_mode, TensorFormat data_format, 59 FilterTensorFormat filter_format, Tensor* output); 60 }; 61 #endif // GOOGLE_CUDA 62 63 } // namespace tensorflow 64 65 #endif // TENSORFLOW_CONTRIB_FUSED_CONV_KERNELS_FUSED_CONV2D_BIAS_ACTIVATION_OP_H_ 66