• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2018 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_GRAPPLER_OPTIMIZERS_EVALUATION_UTILS_H_
17 #define TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_EVALUATION_UTILS_H_
18 
19 #define EIGEN_USE_THREADS
20 
21 #include "tensorflow/core/framework/device_base.h"
22 #include "tensorflow/core/framework/node_def.pb.h"
23 #include "tensorflow/core/framework/op_kernel.h"
24 #include "tensorflow/core/framework/tensor.pb.h"
25 #include "tensorflow/core/lib/gtl/inlined_vector.h"
26 
27 namespace Eigen {
28 class ThreadPoolInterface;
29 class ThreadPoolWrapper;
30 }  // namespace Eigen
31 
32 namespace tensorflow {
33 namespace grappler {
34 
35 class DeviceSimple : public DeviceBase {
36  public:
37   DeviceSimple();
38   ~DeviceSimple();
39 
40   Status MakeTensorFromProto(const TensorProto& tensor_proto,
41                              const AllocatorAttributes alloc_attrs,
42                              Tensor* tensor) override;
43 
GetAllocator(AllocatorAttributes attr)44   Allocator* GetAllocator(AllocatorAttributes attr) override {
45     return cpu_allocator();
46   }
47 
48  private:
49   DeviceBase::CpuWorkerThreads eigen_worker_threads_;
50   std::unique_ptr<Eigen::ThreadPoolInterface> eigen_threadpool_wrapper_;
51   std::unique_ptr<Eigen::ThreadPoolDevice> eigen_device_;
52 };
53 
54 Status EvaluateNode(const NodeDef& node,
55                     const gtl::InlinedVector<TensorValue, 4>& inputs,
56                     DeviceBase* cpu_device, ResourceMgr* resource_mgr,
57                     gtl::InlinedVector<TensorValue, 4>* output);
58 
59 }  // end namespace grappler
60 }  // end namespace tensorflow
61 
62 #endif  // TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_EVALUATION_UTILS_H_
63