Home | History | Annotate | Download | only in kernels
      1 /* Copyright 2016 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_CORE_KERNELS_XSMM_CONV2D_H_
     17 #define TENSORFLOW_CORE_KERNELS_XSMM_CONV2D_H_
     18 
     19 #include "tensorflow/core/framework/types.h"
     20 #include "tensorflow/core/util/tensor_format.h"
     21 
     22 #include "include/libxsmm.h"
     23 #include "include/libxsmm_dnn.h"
     24 
     25 namespace tensorflow {
     26 
     27 class OpKernelContext;
     28 
     29 // XsmmConv2D is a wrapper for libxsmm direct convolutions.
     30 
     31 // Returns true if convolution operation specified by function arguments
     32 // can use XsmmConv2D implementation, and false otherwise.
     33 bool CanUseXsmmConv2D(const libxsmm_dnn_conv_desc& desc,
     34                       TensorFormat data_format);
     35 
     36 namespace functor {
     37 
     38 template <typename Device, typename T>
     39 struct XsmmFwdConv2D {
     40   bool operator()(OpKernelContext* ctx, const libxsmm_dnn_conv_desc& desc,
     41                   const T* input, const T* filter, T* output);
     42 };
     43 
     44 template <typename Device, typename T>
     45 struct XsmmBkwInputConv2D {
     46   bool operator()(OpKernelContext* ctx, const libxsmm_dnn_conv_desc& desc,
     47                   T* input, const T* filter, const T* output);
     48 };
     49 
     50 template <typename Device, typename T>
     51 struct XsmmBkwFilterConv2D {
     52   bool operator()(OpKernelContext* ctx, const libxsmm_dnn_conv_desc& desc,
     53                   const T* input, T* filter, const T* output);
     54 };
     55 
     56 }  // namespace functor
     57 
     58 }  // namespace tensorflow
     59 
     60 #endif  // TENSORFLOW_CORE_KERNELS_XSMM_CONV2D_H_
     61