• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2017 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 #include "tensorflow/compiler/xla/executable_run_options.h"
17 
18 #include <atomic>
19 
20 #include "absl/strings/str_cat.h"
21 
22 namespace xla {
23 
RunId()24 RunId::RunId() {
25   static std::atomic<int64> counter{0};
26   data_ = counter.fetch_add(1);
27 }
28 
operator ==(const RunId & a,const RunId & b)29 bool operator==(const RunId& a, const RunId& b) { return a.data_ == b.data_; }
30 
ToString() const31 std::string RunId::ToString() const { return absl::StrCat("RunId: ", data_); }
32 
set_device_ordinal(int device_ordinal)33 ExecutableRunOptions& ExecutableRunOptions::set_device_ordinal(
34     int device_ordinal) {
35   device_ordinal_ = device_ordinal;
36   return *this;
37 }
38 
device_ordinal() const39 int ExecutableRunOptions::device_ordinal() const { return device_ordinal_; }
40 
set_allocator(stream_executor::DeviceMemoryAllocator * allocator)41 ExecutableRunOptions& ExecutableRunOptions::set_allocator(
42     stream_executor::DeviceMemoryAllocator* allocator) {
43   allocator_ = allocator;
44   return *this;
45 }
46 
allocator() const47 stream_executor::DeviceMemoryAllocator* ExecutableRunOptions::allocator()
48     const {
49   return allocator_;
50 }
51 
set_stream(stream_executor::Stream * stream)52 ExecutableRunOptions& ExecutableRunOptions::set_stream(
53     stream_executor::Stream* stream) {
54   stream_ = stream;
55   return *this;
56 }
57 
stream() const58 stream_executor::Stream* ExecutableRunOptions::stream() const {
59   return stream_;
60 }
61 
set_host_to_device_stream(stream_executor::Stream * stream)62 ExecutableRunOptions& ExecutableRunOptions::set_host_to_device_stream(
63     stream_executor::Stream* stream) {
64   host_to_device_stream_ = stream;
65   return *this;
66 }
67 
host_to_device_stream() const68 stream_executor::Stream* ExecutableRunOptions::host_to_device_stream() const {
69   return host_to_device_stream_;
70 }
71 
set_intra_op_thread_pool(const Eigen::ThreadPoolDevice * intra_op_thread_pool)72 ExecutableRunOptions& ExecutableRunOptions::set_intra_op_thread_pool(
73     const Eigen::ThreadPoolDevice* intra_op_thread_pool) {
74   intra_op_thread_pool_ = intra_op_thread_pool;
75   return *this;
76 }
77 
intra_op_thread_pool() const78 const Eigen::ThreadPoolDevice* ExecutableRunOptions::intra_op_thread_pool()
79     const {
80   return intra_op_thread_pool_;
81 }
82 
set_execution_profile(ExecutionProfile * profile)83 ExecutableRunOptions& ExecutableRunOptions::set_execution_profile(
84     ExecutionProfile* profile) {
85   execution_profile_ = profile;
86   return *this;
87 }
88 
execution_profile() const89 ExecutionProfile* ExecutableRunOptions::execution_profile() const {
90   return execution_profile_;
91 }
92 
set_device_assignment(const DeviceAssignment * device_assignment)93 ExecutableRunOptions& ExecutableRunOptions::set_device_assignment(
94     const DeviceAssignment* device_assignment) {
95   device_assignment_ = device_assignment;
96   return *this;
97 }
98 
device_assignment() const99 const DeviceAssignment* ExecutableRunOptions::device_assignment() const {
100   return device_assignment_;
101 }
102 
set_rng_seed(int rng_seed)103 ExecutableRunOptions& ExecutableRunOptions::set_rng_seed(int rng_seed) {
104   rng_seed_ = rng_seed;
105   return *this;
106 }
107 
rng_seed() const108 int ExecutableRunOptions::rng_seed() const { return rng_seed_; }
109 
set_run_id(RunId id)110 ExecutableRunOptions& ExecutableRunOptions::set_run_id(RunId id) {
111   run_id_ = id;
112   return *this;
113 }
114 
run_id() const115 RunId ExecutableRunOptions::run_id() const { return run_id_; }
116 
117 }  // namespace xla
118