• 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_COMMON_RUNTIME_THREADPOOL_DEVICE_H_
17 #define TENSORFLOW_CORE_COMMON_RUNTIME_THREADPOOL_DEVICE_H_
18 
19 #include "tensorflow/core/common_runtime/device_factory.h"
20 #include "tensorflow/core/common_runtime/local_device.h"
21 
22 namespace tensorflow {
23 
24 // CPU device implementation.
25 class ThreadPoolDevice : public LocalDevice {
26  public:
27   ThreadPoolDevice(const SessionOptions& options, const string& name,
28                    Bytes memory_limit, const DeviceLocality& locality,
29                    Allocator* allocator);
30   ~ThreadPoolDevice() override;
31 
32   Allocator* GetAllocator(AllocatorAttributes attr) override;
33   Allocator* GetScopedAllocator(AllocatorAttributes attr,
34                                 int64 step_id) override;
GetScopedAllocatorMgr()35   ScopedAllocatorMgr* GetScopedAllocatorMgr() const override {
36     return scoped_allocator_mgr_.get();
37   }
38   Status MakeTensorFromProto(const TensorProto& tensor_proto,
39                              const AllocatorAttributes alloc_attrs,
40                              Tensor* tensor) override;
41 
Sync()42   Status Sync() override { return Status::OK(); }
43 
44  private:
45   Allocator* allocator_;  // Not owned
46   std::unique_ptr<ScopedAllocatorMgr> scoped_allocator_mgr_;
47 };
48 
49 }  // namespace tensorflow
50 
51 #endif  // TENSORFLOW_CORE_COMMON_RUNTIME_THREADPOOL_DEVICE_H_
52