1/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15
16#ifndef TENSORFLOW_CORE_KERNELS_BETAINC_OP_H_
17#define TENSORFLOW_CORE_KERNELS_BETAINC_OP_H_
18// Functor definition for BetaincOp, must be compilable by nvcc.
19
20#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
21#include "tensorflow/core/framework/tensor_types.h"
22
23namespace tensorflow {
24namespace functor {
25
26// Functor used by BetaincOp to do the computations.
27template <typename Device, typename T, int NDIM>
28struct Betainc {
29 void operator()(const Device& d, typename TTypes<T, NDIM>::ConstTensor a,
30 typename TTypes<T, NDIM>::ConstTensor b,
31 typename TTypes<T, NDIM>::ConstTensor x,
32 typename TTypes<T, NDIM>::Tensor output) {
33 output.device(d) = Eigen::betainc(a, b, x);
34 }
35
36 void BCast(const Device& d, typename TTypes<T, NDIM>::ConstTensor a,
37 const typename Eigen::array<Eigen::DenseIndex, NDIM>& bcast_a,
38 typename TTypes<T, NDIM>::ConstTensor b,
39 const typename Eigen::array<Eigen::DenseIndex, NDIM>& bcast_b,
40 typename TTypes<T, NDIM>::ConstTensor x,
41 const typename Eigen::array<Eigen::DenseIndex, NDIM>& bcast_x,
42 typename TTypes<T, NDIM>::Tensor output) {
43 output.device(d) = Eigen::betainc(
44 a.broadcast(bcast_a), b.broadcast(bcast_b), x.broadcast(bcast_x));
45 }
46};
47
48} // namespace functor
49} // namespace tensorflow
50
51#endif // TENSORFLOW_CORE_KERNELS_BETAINC_OP_H_
52