• 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_RANDOM_OP_H_
17 #define TENSORFLOW_CORE_KERNELS_RANDOM_OP_H_
18 
19 #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
20 #include "tensorflow/core/lib/random/random_distributions.h"
21 
22 namespace tensorflow {
23 
24 class OpKernelContext;
25 
26 namespace functor {
27 
28 template <typename Device, class Distribution>
29 struct FillPhiloxRandom;
30 
31 typedef Eigen::ThreadPoolDevice CPUDevice;
32 // Declares the partially CPU-specialized functor struct.
33 //
34 // NOTE: Due to inlining done by the compiler, you may need to add
35 // explicit instantiation of the functor in random_op.cc.  See example
36 // functor::FillPhiloxRandom<CPUDevice, random::UniformDistribution>.
37 template <class Distribution>
38 struct FillPhiloxRandom<CPUDevice, Distribution> {
39   void operator()(OpKernelContext* ctx, const CPUDevice& d,
40                   random::PhiloxRandom gen,
41                   typename Distribution::ResultElementType* data, int64 size,
42                   Distribution dist);
43 };
44 
45 #if GOOGLE_CUDA
46 typedef Eigen::GpuDevice GPUDevice;
47 // Declares the partially GPU-specialized functor struct.
48 template <class Distribution>
49 struct FillPhiloxRandom<GPUDevice, Distribution> {
50   void operator()(OpKernelContext* ctx, const GPUDevice& d,
51                   random::PhiloxRandom gen,
52                   typename Distribution::ResultElementType* data, int64 size,
53                   Distribution dist);
54 };
55 #endif  // GOOGLE_CUDA
56 
57 #if TENSORFLOW_USE_SYCL
58 typedef Eigen::SyclDevice SYCLDevice;
59 // Declares the partially SYCL-specialized functor struct.
60 template <class Distribution>
61 struct FillPhiloxRandom<SYCLDevice, Distribution> {
62   void operator()(OpKernelContext* ctx, const SYCLDevice& d,
63                   random::PhiloxRandom gen,
64                   typename Distribution::ResultElementType* data, int64 size,
65                   Distribution dist);
66 };
67 #endif  // TENSORFLOW_USE_SYCL
68 
69 }  // namespace functor
70 }  // namespace tensorflow
71 
72 #endif  // TENSORFLOW_CORE_KERNELS_RANDOM_OP_H_
73