1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#ifndef TENSORFLOW_KERNELS_DENSE_UPDATE_OPS_H_
#define TENSORFLOW_KERNELS_DENSE_UPDATE_OPS_H_
#include "tensorflow/core/framework/tensor_types.h"
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
namespace tensorflow {
enum DenseUpdateType { ADD, SUB, ASSIGN };
namespace functor {
template <typename Device, typename T, DenseUpdateType OP>
struct DenseUpdate;
template <typename Device, typename T>
struct DenseUpdate<Device, T, ADD> {
void operator()(const Device& d, typename TTypes<T>::Flat params,
typename TTypes<T>::ConstFlat update) {
params.device(d) += update;
}
};
template <typename Device, typename T>
struct DenseUpdate<Device, T, SUB> {
void operator()(const Device& d, typename TTypes<T>::Flat params,
typename TTypes<T>::ConstFlat update) {
params.device(d) -= update;
}
};
template <typename Device, typename T>
struct DenseUpdate<Device, T, ASSIGN> {
void operator()(const Device& d, typename TTypes<T>::Flat params,
typename TTypes<T>::ConstFlat update) {
params.device(d) = update;
}
};
} // end namespace functor
} // end namespace tensorflow
#endif // TENSORFLOW_KERNELS_DENSE_UPDATE_OPS_H_
|