• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2015 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_FILL_FUNCTOR_H_
17 #define TENSORFLOW_CORE_KERNELS_FILL_FUNCTOR_H_
18 
19 #define EIGEN_USE_THREADS
20 
21 #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
22 #include "tensorflow/core/framework/tensor_types.h"
23 #include "tensorflow/core/framework/types.h"
24 
25 namespace tensorflow {
26 namespace functor {
27 
28 template <typename Device, typename T>
29 struct FillFunctor {
30   // Computes on device "d": out = out.constant(in(0)),
31   void operator()(const Device& d, typename TTypes<T>::Flat out,
32                   typename TTypes<T>::ConstScalar in);
33 };
34 
35 template <typename Device, typename T>
36 struct SetZeroFunctor {
37   // Computes on device "d": out = out.setZero(),
38   void operator()(const Device& d, typename TTypes<T>::Flat out);
39 };
40 
41 // Partial specialization of SetZeroFunctor<Device=Eigen::ThreadPoolDevice, T>.
42 template <typename T>
43 struct SetZeroFunctor<Eigen::ThreadPoolDevice, T> {
44   void operator()(const Eigen::ThreadPoolDevice& d,
45                   typename TTypes<T>::Flat out);
46 };
47 
48 
49 template <>
50 struct SetZeroFunctor<Eigen::ThreadPoolDevice, tstring> {
51   void operator()(const Eigen::ThreadPoolDevice& d,
52                   typename TTypes<tstring>::Flat out);
53 };
54 
55 template <typename Device, typename T>
56 struct SetOneFunctor {
57   // Computes on device "d": out = out.setOne(),
58   void operator()(const Device& d, typename TTypes<T>::Flat out);
59 };
60 
61 // Partial specialization of SetOneFunctor<Device=Eigen::ThreadPoolDevice, T>.
62 template <typename T>
63 struct SetOneFunctor<Eigen::ThreadPoolDevice, T> {
64   void operator()(const Eigen::ThreadPoolDevice& d,
65                   typename TTypes<T>::Flat out);
66 };
67 
68 
69 template <>
70 struct SetOneFunctor<Eigen::ThreadPoolDevice, tstring> {
71   void operator()(const Eigen::ThreadPoolDevice& d,
72                   typename TTypes<tstring>::Flat out);
73 };
74 
75 }  // namespace functor
76 }  // namespace tensorflow
77 
78 #endif  // TENSORFLOW_CORE_KERNELS_FILL_FUNCTOR_H_
79