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

Method AddAssignment

tensorflow/compiler/xla/service/buffer_assignment.cc:235–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235void BufferAllocation::AddAssignment(const HloValue& buffer, int64 offset,
236 int64 size) {
237 VLOG(4) << "Adding the following buffer to allocation #" << index()
238 << absl::StrFormat(" (size=%d, offset=%d) %s", size, offset,
239 buffer.ToShortString());
240 CHECK(!assigned_buffers_.contains(&buffer))
241 << "LogicalBuffer " << buffer << " already assigned to allocation "
242 << index_;
243 CHECK_LE(offset, size_) << "LogicalBuffer " << buffer
244 << " offset out of range";
245 CHECK_LE(offset + size, size_)
246 << "LogicalBuffer " << buffer
247 << " size out of range at offset: " << offset << " with size: " << size;
248 CHECK_EQ(buffer.color(), color())
249 << "Buffer color " << buffer.color() << " for buffer " << buffer
250 << " does not match allocation color " << color() << ".";
251 OffsetSize offset_size;
252 offset_size.offset = offset;
253 offset_size.size = size;
254 assigned_buffers_.emplace(&buffer, offset_size);
255 // For debugging purposes, store the assigned memory space in the
256 // instruction's layout.
257 for (HloPosition position : buffer.positions()) {
258 Shape* shape = ShapeUtil::GetMutableSubshape(
259 position.instruction->mutable_shape(), position.index);
260 if (shape->has_layout()) {
261 shape->mutable_layout()->set_memory_space(buffer.color().value());
262 }
263 }
264}
265
266BufferAllocationProto BufferAllocation::ToProto() const {
267 BufferAllocationProto proto;

Callers 4

MaybeAssignBufferMethod · 0.80
AssignPresetBuffersMethod · 0.80

Calls 15

containsMethod · 0.80
has_layoutMethod · 0.80
mutable_layoutMethod · 0.80
is_reusableMethod · 0.80
BufferLivesOutMethod · 0.80
set_maybe_live_outMethod · 0.80
ValueLivesOutMethod · 0.80
ToShortStringMethod · 0.45
colorMethod · 0.45
emplaceMethod · 0.45
mutable_shapeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected