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

Method init_holder

paddle/phi/core/string_tensor.cc:125–148  ·  view source on GitHub ↗

TODO(zhoushunjie): need to remove it for general space

Source from the content-addressed store, hash-verified

123
124// TODO(zhoushunjie): need to remove it for general space
125void StringTensor::init_holder() {
126 void* ptr = holder_->ptr();
127 auto& place = holder_->place();
128 auto bytes_size = holder_->size();
129 VLOG(6) << "Init StringTensor data with bytes:" << bytes_size;
130 if (place.GetType() == AllocationType::CPU) {
131 std::memset(ptr, 0, bytes_size);
132 } else if (place.GetType() == AllocationType::GPU) {
133#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
134#ifdef PADDLE_WITH_HIP
135 hipMemset(ptr, 0, bytes_size);
136#else
137 cudaMemset(ptr, 0, bytes_size);
138#endif
139#endif
140 } else {
141 // TODO(zhoushunjie): Need to support more places
142 PADDLE_THROW(
143 errors::Unimplemented("StringTensor can only be created in CPU or GPU "
144 "place. But now attempts to "
145 "create StringTensor on %s",
146 place.DebugString()));
147 }
148}
149
150void* StringTensor::AllocateFrom(Allocator* allocator,
151 DataType dtype,

Callers

nothing calls this directly

Calls 5

ptrMethod · 0.45
placeMethod · 0.45
sizeMethod · 0.45
GetTypeMethod · 0.45
DebugStringMethod · 0.45

Tested by

no test coverage detected