MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / LocalDeviceState

Method LocalDeviceState

tensorflow/compiler/xla/python/local_device_state.cc:27–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25namespace xla {
26
27LocalDeviceState::LocalDeviceState(se::StreamExecutor* executor,
28 LocalClient* client,
29 bool synchronous_deallocation,
30 bool asynchronous, bool allow_event_reuse)
31 : synchronous_deallocation_(synchronous_deallocation),
32 event_pool_(allow_event_reuse),
33 compute_semaphore_(/*capacity=*/asynchronous ? 32 : 1),
34 executor_(executor),
35 client_(client),
36 prng_seed_generator_(prng_seed_device_()),
37 prng_seed_distribution_(std::numeric_limits<int>::min(),
38 std::numeric_limits<int>::max()) {
39 compute_stream_ = absl::make_unique<se::Stream>(executor);
40 host_to_device_stream_ = absl::make_unique<se::Stream>(executor);
41 callback_stream_ = absl::make_unique<se::Stream>(executor);
42 compute_stream_->Init();
43 host_to_device_stream_->Init();
44 callback_stream_->Init();
45 device_to_host_streams_.reserve(kNumDeviceToHostStreams);
46 for (int i = 0; i < kNumDeviceToHostStreams; ++i) {
47 auto stream = absl::make_unique<se::Stream>(executor);
48 stream->Init();
49 device_to_host_streams_.push_back(std::move(stream));
50 }
51 device_to_device_streams_.reserve(kNumDeviceToDeviceStreams);
52 for (int i = 0; i < kNumDeviceToDeviceStreams; ++i) {
53 auto stream = absl::make_unique<se::Stream>(executor);
54 stream->Init();
55 device_to_device_streams_.push_back(std::move(stream));
56 }
57 execute_thread_ = absl::make_unique<WorkerThread>(tensorflow::Env::Default(),
58 "py_xla_execute");
59 callback_thread_ = absl::make_unique<WorkerThread>(tensorflow::Env::Default(),
60 "py_xla_callback");
61}
62
63LocalDeviceState::~LocalDeviceState() {
64 Status status = SynchronizeAllActivity();

Callers

nothing calls this directly

Calls 6

DefaultFunction · 0.85
minFunction · 0.50
maxFunction · 0.50
InitMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected