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

Method CreateUninitialized

tensorflow/compiler/xrt/xrt_state.cc:197–218  ·  view source on GitHub ↗

static*/

Source from the content-addressed store, hash-verified

195}
196
197/*static*/ Status XRTTupleAllocation::CreateUninitialized(
198 const xla::Shape& shape, XRTMemoryManager* memory_manager,
199 xla::Backend* backend, int device_ordinal,
200 XRTTupleAllocation** allocation) {
201 std::unique_ptr<xla::ScopedShapedBuffer> scoped_buffer;
202 TF_RETURN_IF_ERROR(AllocateScopedShapedBuffer(
203 memory_manager, backend, device_ordinal, shape, &scoped_buffer));
204
205 // By releasing the ScopedShapedBuffer we ensure that the underlying storage
206 // won't be freed when the buffer goes out of scope at the end of this
207 // call. To avoid a leak, there must be no error-case returns from here until
208 // the end of the method.
209 auto shaped_buffer = scoped_buffer->release();
210 *allocation = new XRTTupleAllocation(
211 device_ordinal, backend->memory_allocator(),
212 shaped_buffer.on_host_shape(), shaped_buffer.on_device_shape());
213 (*allocation)
214 ->InitializeFromShapedBuffer(shaped_buffer, backend->memory_allocator(),
215 device_ordinal);
216 (*allocation)->SetDeviceMemorySize();
217 return Status::OK();
218}
219
220/*static*/ Status XRTTupleAllocation::CreateFromBuffer(
221 const xla::ShapedBuffer& shaped_buffer, xla::Backend* backend,

Callers

nothing calls this directly

Calls 5

SetDeviceMemorySizeMethod · 0.80
releaseMethod · 0.45
memory_allocatorMethod · 0.45

Tested by

no test coverage detected