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_LITE_KERNELS_INTERNAL_OPTIMIZED_EIGEN_SPATIAL_CONVOLUTIONS_H_
17 #define TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_EIGEN_SPATIAL_CONVOLUTIONS_H_
18 
19 #define EIGEN_USE_CUSTOM_THREAD_POOL
20 #define EIGEN_USE_THREADS
21 
22 #define Eigen EigenForTFLite
23 
24 // NOTE: We need to define our own tensor contraction dispatch method before
25 // including the unsupported/Eigen/CXX11/Tensor header in order to reduce the
26 // total number of kernel instantiations.
27 // If you have trouble simply undef out the reducer macro e.g.
28 // TFLITE_REDUCE_INSTANTIATIONS, but be aware this will make
29 // the binary much bigger!
30 #define TFLITE_REDUCE_INSTANTIATIONS
31 #if defined(TFLITE_REDUCE_INSTANTIATIONS)
32 // Override Eigen tensor contraction dispatch method.
33 #define TENSOR_CONTRACTION_DISPATCH(METHOD, ALIGNMENT, ARGS)                  \
34   if (this->m_lhs_inner_dim_contiguous && this->m_rhs_inner_dim_contiguous && \
35       !this->m_rhs_inner_dim_reordered) {                                     \
36     METHOD<true, true, false, ALIGNMENT> ARGS;                                \
37   } else {                                                                    \
38     eigen_assert(false && "Unsupported contraction formats");                 \
39   }
40 #endif
41 
42 #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
43 #include "tensorflow/core/kernels/eigen_spatial_convolutions-inl.h"
44 
45 #endif  // TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_EIGEN_SPATIAL_CONVOLUTIONS_H_
46