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

Method CreateAndTransfer

tensorflow/compiler/xrt/xrt_state.cc:169–195  ·  view source on GitHub ↗

static*/

Source from the content-addressed store, hash-verified

167}
168
169/*static*/ Status XRTTupleAllocation::CreateAndTransfer(
170 const xla::LiteralBase& literal, XRTMemoryManager* memory_manager,
171 xla::Backend* backend, int device_ordinal,
172 XRTTupleAllocation** allocation) {
173 auto transfer_manager = backend->transfer_manager();
174 std::unique_ptr<xla::ScopedShapedBuffer> scoped_buffer;
175 TF_RETURN_IF_ERROR(AllocateScopedShapedBuffer(memory_manager, backend,
176 device_ordinal, literal.shape(),
177 &scoped_buffer));
178 TF_ASSIGN_OR_RETURN(auto stream, backend->BorrowStream(device_ordinal));
179 TF_RETURN_IF_ERROR(transfer_manager->TransferLiteralToDevice(
180 stream.get(), literal, *scoped_buffer));
181
182 // By releasing the ScopedShapedBuffer we ensure that the underlying storage
183 // won't be freed when the buffer goes out of scope at the end of this
184 // call. To avoid a leak, there must be no error-case returns from here until
185 // the end of the method.
186 auto shaped_buffer = scoped_buffer->release();
187 *allocation = new XRTTupleAllocation(
188 device_ordinal, backend->memory_allocator(),
189 shaped_buffer.on_host_shape(), shaped_buffer.on_device_shape());
190 (*allocation)
191 ->InitializeFromShapedBuffer(shaped_buffer, backend->memory_allocator(),
192 device_ordinal);
193 (*allocation)->SetDeviceMemorySize();
194 return Status::OK();
195}
196
197/*static*/ Status XRTTupleAllocation::CreateUninitialized(
198 const xla::Shape& shape, XRTMemoryManager* memory_manager,

Callers

nothing calls this directly

Calls 9

SetDeviceMemorySizeMethod · 0.80
transfer_managerMethod · 0.45
shapeMethod · 0.45
getMethod · 0.45
releaseMethod · 0.45
memory_allocatorMethod · 0.45

Tested by

no test coverage detected