MCPcopy Create free account
hub / github.com/apache/arrow / device_type

Method device_type

cpp/src/arrow/array/data.cc:235–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235DeviceAllocationType ArrayData::device_type() const {
236 // we're using 0 as a sentinel value for NOT YET ASSIGNED
237 // there is explicitly no constant DeviceAllocationType to represent
238 // the "UNASSIGNED" case as it is invalid for data to not have an
239 // assigned device type. If it's still 0 at the end, then we return
240 // CPU as the allocation device type
241 int type = 0;
242 for (const auto& buf : buffers) {
243 if (!buf) continue;
244#ifdef NDEBUG
245 return buf->device_type();
246#else
247 if (type == 0) {
248 type = static_cast<int>(buf->device_type());
249 } else {
250 DCHECK_EQ(type, static_cast<int>(buf->device_type()));
251 }
252#endif
253 }
254
255 for (const auto& child : child_data) {
256 if (!child) continue;
257#ifdef NDEBUG
258 return child->device_type();
259#else
260 if (type == 0) {
261 type = static_cast<int>(child->device_type());
262 } else {
263 DCHECK_EQ(type, static_cast<int>(child->device_type()));
264 }
265#endif
266 }
267
268 if (dictionary) {
269#ifdef NDEBUG
270 return dictionary->device_type();
271#else
272 if (type == 0) {
273 type = static_cast<int>(dictionary->device_type());
274 } else {
275 DCHECK_EQ(type, static_cast<int>(dictionary->device_type()));
276 }
277#endif
278 }
279
280 return type == 0 ? DeviceAllocationType::kCPU : static_cast<DeviceAllocationType>(type);
281}
282
283// ----------------------------------------------------------------------
284// Methods for ArraySpan

Callers 11

device_typesMethod · 0.45
SetMemoryManagerFunction · 0.45
ViewBufferFromMethod · 0.45
ViewBufferToMethod · 0.45
device_typesMethod · 0.45
PrintMethod · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
device_typeFunction · 0.45
ArrayDataFunction · 0.45
VisitArrayMethod · 0.45

Calls

no outgoing calls

Tested by 2

TEST_FFunction · 0.36
TEST_FFunction · 0.36