MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / mutable_data

Method mutable_data

paddle/phi/core/string_tensor.cc:194–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194dtype::pstring* StringTensor::mutable_data(const Place& place,
195 size_t requested_size) {
196 PADDLE_ENFORCE_GE(
197 numel(),
198 0,
199 common::errors::PreconditionNotMet(
200 "The Tensor's element number must be equal or greater than zero. "
201 "The Tensor's shape is [",
202 dims(),
203 "] now"));
204 size_t size = numel() * SizeOf(dtype());
205 if (requested_size && (requested_size > size)) {
206 size = requested_size;
207 }
208
209 /* some versions of paddle::variant don't have operator!= */
210 if (holder_ == nullptr || !(holder_->place() == place) ||
211 holder_->size() < size + meta_.offset) {
212 holder_.reset();
213 holder_ = memory_utils::AllocShared(place, size);
214 // Initialize the allocated bytes
215 init_holder();
216 meta_.offset = 0;
217 }
218 uintptr_t ptr = reinterpret_cast<uintptr_t>(holder_->ptr()) + meta_.offset;
219 return reinterpret_cast<dtype::pstring*>(ptr);
220}
221
222} // namespace phi

Callers 2

ReshardPToSWithPaddingFunction · 0.45

Calls 9

dimsFunction · 0.85
SizeOfFunction · 0.85
numelFunction · 0.70
dtypeFunction · 0.70
AllocSharedFunction · 0.50
placeMethod · 0.45
sizeMethod · 0.45
resetMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected