-
Notifications
You must be signed in to change notification settings - Fork 699
/
Copy pathNNPIResource.cpp
618 lines (563 loc) · 20.7 KB
/
NNPIResource.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
/*
* Copyright (c) Glow Contributors. See CONTRIBUTORS file.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "NNPIResource.h"
#include "InferenceContext.h"
#include "NNPIAdapterContainer.h"
#include "NNPIUtils.h"
#include "nnpi_inference.h"
#include <fstream>
#include <iomanip>
#include <sstream>
static size_t CalcDescSize(const NNPIResourceDesc *desc) {
if (desc->numDims == 0) {
return 0;
}
size_t elements = 1;
for (uint32_t d = 0; d < desc->numDims; d++) {
elements *= desc->dims[d];
}
size_t elemSize = 0;
switch (desc->dataType) {
case NNPI_INF_PRECISION_FLOAT32:
case NNPI_INF_PRECISION_INT32:
case NNPI_INF_PRECISION_UINT32:
elemSize = 4;
break;
case NNPI_INF_PRECISION_FLOAT16:
elemSize = 2;
break;
case NNPI_INF_PRECISION_INT8:
case NNPI_INF_PRECISION_UINT8:
// case NNPI_INF_PRECISION_BOOLEAN://todo: uncomment once supported
elemSize = 1;
break;
default:
LOG_AND_RETURN_IF(ERROR, true, "Invalid precision", 0);
break;
}
return elements * elemSize;
}
static std::string ConvertHexTextFormat(void *data, size_t size) {
std::stringstream ss;
uint8_t *buf = reinterpret_cast<uint8_t *>(data);
for (size_t cl = 0; cl < size; cl += 64) {
size_t size_to_read = std::min((size_t)64, size - cl);
for (size_t i = 0; i < size_to_read; i++) {
ss << std::setfill('0') << std::setw(2) << std::uppercase << std::hex
<< (uint32_t)(buf[cl + (size_to_read - 1 - i)]);
}
ss << "\n";
}
return ss.str();
}
static void DumpToFile(const std::string &filename, void *data, size_t size) {
std::fstream fs(filename, std::ios::out | std::ios::binary);
if (fs.is_open()) {
auto res = ConvertHexTextFormat(data, size);
fs << res;
fs.close();
} else {
LOG(ERROR) << "cannot open the file \"" << filename << "\" for writing";
}
}
namespace glow {
namespace runtime {
static std::shared_ptr<NNPIResource>
findResourceForDevice(const ResourceUsers &users, NNPIDeviceContext device) {
for (auto reader : users.readers) {
if (reader && reader->getDevice() == device) {
return reader;
}
}
for (auto writer : users.writers) {
if (writer && writer->getDevice() == device) {
return writer;
}
}
return nullptr;
}
NNPIResource::NNPIResource() {
pAdapter_ = nullptr;
device_ = NNPI_INVALID_NNPIHANDLE;
memset(name_, 0, sizeof(name_));
memset(&desc_, 0, sizeof(desc_));
deviceResource_ = NNPI_INVALID_NNPIHANDLE;
hostResource_ = NNPI_INVALID_NNPIHANDLE;
hostPtr_ = nullptr;
copyCommand_ = NNPI_INVALID_NNPIHANDLE;
partialSize_ = -1;
usage_ = ResourceUsage::None;
deviceOptions_ = nullptr;
cmdListIdx_ = UINT32_MAX;
ownsDeviceResource_ = true;
ownsHostResource_ = false;
p2pDevice_ = NNPI_INVALID_NNPIHANDLE;
p2pDeviceResource_ = NNPI_INVALID_NNPIHANDLE;
}
NNPIResource::~NNPIResource() {
if (copyCommand_ != NNPI_INVALID_NNPIHANDLE) {
LOG_NNPI_INF_IF_ERROR(nnpiCopyCommandDestroy(copyCommand_),
"Failed to destroy NNPI copy command");
}
if (ownsDeviceResource_ && (deviceResource_ != NNPI_INVALID_NNPIHANDLE)) {
LOG_NNPI_INF_IF_ERROR(nnpiDeviceResourceDestroy(deviceResource_),
"Failed to destroy NNPI device resource");
}
if (ownsHostResource_ && (hostResource_ != NNPI_INVALID_NNPIHANDLE)) {
LOG_NNPI_INF_IF_ERROR(nnpiHostResourceDestroy(hostResource_),
"Failed to destroy NNPI host resource");
}
// Do not destroy the adapter or device context as the Resource doesn't own
// them but only keeps reference for it's usage.
}
bool NNPIResource::init(const NNPIObjectName name,
std::shared_ptr<NNPIDeviceOptions> deviceOptions,
NNPIAdapterContainer *adapter, NNPIDeviceContext device,
const NNPIResourceDesc *desc,
NNPIResource::ResourceUsage usage,
PlaceholderUsageMap *phUsage) {
if (name == nullptr || desc == nullptr || deviceOptions == nullptr) {
return false;
}
if (deviceOptions->inferOnDevice &&
(adapter->getHandle() == NNPI_INVALID_NNPIHANDLE ||
device == NNPI_INVALID_NNPIHANDLE)) {
return false;
}
std::strncpy(name_, name, sizeof(NNPIObjectName));
device_ = device;
pAdapter_ = adapter;
deviceOptions_ = deviceOptions;
usage_ = usage;
desc_ = *desc;
// At this point it's safe to call NNPIResource::dump(), so do so if we return
// false, representing some issue has occurred during initialization.
ScopeGuard dumpResourceInfo(
[&]() { LOG(ERROR) << "Error initializing " << dump(); });
ResourceUsers *users = nullptr;
if (phUsage) {
users = &(phUsage->at(name_));
LOG_AND_RETURN_IF_NOT(ERROR, users, "Invalid resource users", false);
}
if (!deviceOptions_->inferOnDevice) {
// Handle stuff for ice ref (or compile only path).
size_t resourceSize = CalcDescSize(&desc_);
LOG_AND_RETURN_IF(ERROR, resourceSize == 0,
"Failed to calculate resource size", false);
refStorage_.resize(resourceSize);
if (refStorage_.size() != resourceSize) {
LOG_ERROR_IF_NOT(0) << "Failed to allocate memory for reference storage";
return false;
}
hostPtr_ = &(refStorage_[0]);
dumpResourceInfo.dismiss();
return true;
}
if (deviceOptions_->disableDRT || (users && users->disableDRT)) {
switch (usage_) {
case ResourceUsage::DRTInput:
usage_ = ResourceUsage::InputResource;
break;
case ResourceUsage::DRTOutput:
usage_ = ResourceUsage::OutputResource;
break;
default:; // Do nothing.
}
}
if (deviceOptions_->disableP2P || (users && users->disableP2P)) {
switch (usage_) {
case ResourceUsage::P2PInput:
usage_ = ResourceUsage::InputResource;
break;
case ResourceUsage::P2POutput:
usage_ = ResourceUsage::OutputResource;
break;
default:; // Do nothing.
}
}
// Create host resource (pinned and aligned allocation).
NNPIResourceDesc hostResDesc =
desc_; // Make a copy of the desc to overwrite attributes.
hostResDesc.hostAttrib.locklessExecution =
1; // Set host resource to lockless.
switch (usage_) {
case ResourceUsage::InputResource:
case ResourceUsage::OutputResource: {
hostPtr_ = users ? users->tensor->getUnsafePtr() : nullptr;
hostResource_ = hostPtr_ ? pAdapter_->getResourceForPtr(hostPtr_)
: NNPI_INVALID_NNPIHANDLE;
if (hostResource_ != NNPI_INVALID_NNPIHANDLE) {
// Tensor bound to placeholder was already allocated as a host resource.
// No need to allocate another one.
ownsHostResource_ = false;
} else { // Allocate a private host resource for DMA.
LOG_NNPI_INF_IF_ERROR_RETURN_FALSE(
nnpiHostResourceCreate(pAdapter_->getHandle(), &hostResDesc,
&hostResource_),
"Failed to create NNPI host resource");
// Query host resource for address (not locking).
LOG_NNPI_INF_IF_ERROR_RETURN_FALSE(
nnpiHostResourceLock(hostResource_, NNPI_LOCKLESS_QUERY_ADDRESS,
UINT32_MAX, &hostPtr_),
"Failed to lock host resource");
memset(hostPtr_, 0,
CalcDescSize(&desc_)); // Clear host resource to zero for compile
// only path (USE_ICE_T).
ownsHostResource_ = true;
}
} break;
case ResourceUsage::StaticInputResource:
case ResourceUsage::P2PInput:
case ResourceUsage::P2POutput:
case ResourceUsage::DRTInput:
case ResourceUsage::DRTOutput:
// No host resource is needed
break;
default:
LOG_AND_RETURN_IF_NOT(ERROR, 0, "Invalid usage", false);
}
// Create device resource.
bool allocateDeviceResource = false;
std::shared_ptr<NNPIResource> sharedResource = nullptr;
if (phUsage) {
sharedResource = findResourceForDevice(*users, device_);
}
switch (usage_) {
case ResourceUsage::InputResource:
case ResourceUsage::OutputResource:
// Normal create.
allocateDeviceResource = true;
break;
case ResourceUsage::StaticInputResource:
case ResourceUsage::DRTInput:
// Potential shared (allocate if doesnt exist).
if (sharedResource) {
// If exists on device - share it.
deviceResource_ = sharedResource->getDeviceResource();
ownsDeviceResource_ = false;
allocateDeviceResource = false;
} else {
allocateDeviceResource = true;
}
break;
case ResourceUsage::P2PInput:
// Create p2p input.
desc_.deviceAttrib.p2pUsage = NNPI_P2P_USAGE_DST;
desc_.deviceAttrib.p2pDepth = 1;
allocateDeviceResource = true;
break;
case ResourceUsage::P2POutput:
// Create p2p output.
desc_.deviceAttrib.p2pUsage = NNPI_P2P_USAGE_SRC;
desc_.deviceAttrib.p2pDepth = 1;
allocateDeviceResource = true;
break;
case ResourceUsage::DRTOutput:
// Must be shared (creation order maintains readers allocated before
// writers).
LOG_AND_RETURN_IF_NOT(
ERROR, sharedResource,
"Missing DRT resource (should have been created already)", false);
deviceResource_ = sharedResource->getDeviceResource();
ownsDeviceResource_ = false;
allocateDeviceResource = false;
break;
default:
LOG_AND_RETURN_IF_NOT(ERROR, 0, "Invalid usage", false);
}
if (allocateDeviceResource) {
LOG_NNPI_INF_IF_ERROR_RETURN_FALSE(
nnpiDeviceResourceCreate(device_, &desc_, &deviceResource_),
"Failed to create NNPI device resource");
}
// Create copy command.
switch (usage_) {
case ResourceUsage::InputResource:
LOG_NNPI_INF_IF_ERROR_RETURN_FALSE(
nnpiCopyCommandCreateHostToDevice(device_, deviceResource_,
hostResource_, ©Command_),
"Failed to create NNPI copy command (input)");
break;
case ResourceUsage::OutputResource:
LOG_NNPI_INF_IF_ERROR_RETURN_FALSE(
nnpiCopyCommandCreateDeviceToHost(device_, hostResource_,
deviceResource_, ©Command_),
"Failed to create NNPI copy command (output)");
break;
case ResourceUsage::P2POutput:
LOG_AND_RETURN_IF_NOT(ERROR, users, "Missing resource users", false);
for (auto reader : users->readers) {
if (reader && reader->getDevice() != device) {
p2pDevice_ = reader->getDevice();
p2pDeviceResource_ = reader->getDeviceResource();
}
}
LOG_AND_RETURN_IF_NOT(ERROR,
(p2pDevice_ != NNPI_INVALID_NNPIHANDLE) &&
(p2pDeviceResource_ != NNPI_INVALID_NNPIHANDLE),
"Can't find p2p counterpart", false);
LOG_NNPI_INF_IF_ERROR_RETURN_FALSE(
nnpiCopyCommandCreateDeviceToDevice(p2pDevice_, p2pDeviceResource_,
device_, deviceResource_,
©Command_),
"Failed to create NNPI copy command (p2p output)");
break;
case ResourceUsage::P2PInput:
// The device resource is copied by the writer in the
// preceding context.
break;
case ResourceUsage::StaticInputResource:
// The device resource doesn't need to be updated before
// inference.
break;
case ResourceUsage::DRTInput:
// The device resource doesn't need to be updated before
// inference.
break;
case ResourceUsage::DRTOutput:
// The device resource doesn't need to be updated before
// inference.
break;
case ResourceUsage::None:
// Do nothing - no copy command needed.
break;
default:
LOG_ERROR_IF_NOT(0) << "Invalid resource usage";
return false;
}
DBG(__FUNCTION__ << dump());
dumpResourceInfo.dismiss();
return true;
}
NNPIInferenceErrorCode
NNPIResource::preInference(Tensor *t, bool partialTensor,
bool requiresLastElementPadding) {
if (usage_ != ResourceUsage::InputResource) {
// Nothing to do here yet.
return NNPI_INF_NO_ERROR;
}
// Update the host resource from the tensor content.
updateHostResourceFromTensor(t, partialTensor, requiresLastElementPadding);
if (deviceOptions_->dumpIOtoFiles) {
size_t unpaddedSize = t->getUnpaddedSizeInBytes();
const bool downcastInt64 = t->getElementType() == glow::ElemKind::Int64ITy;
if (downcastInt64) {
unpaddedSize /= 2;
}
DumpToFile(std::string("input_") + std::string(name_) + ".txt", hostPtr_,
unpaddedSize);
}
return NNPI_INF_NO_ERROR;
}
NNPIInferenceErrorCode NNPIResource::postInference(Tensor *t) {
if (usage_ != ResourceUsage::OutputResource) {
// Nothing to do here yet.
return NNPI_INF_NO_ERROR;
}
char *tensorData = t->getUnsafePtr();
const bool upcastInt64 = t->getElementType() == glow::ElemKind::Int64ITy;
size_t unpaddedSize = t->getUnpaddedSizeInBytes();
if (upcastInt64) {
// TODO: add AVX implementation.
const size_t outputSize = unpaddedSize / t->getType().getElementSize();
int64_t *i64Data = reinterpret_cast<int64_t *>(tensorData);
int32_t *i32Data = reinterpret_cast<int32_t *>(hostPtr_);
// Convert from end to start for the case where (tensorData == hostPtr_).
for (int64_t j = (outputSize - 1); j >= 0; j--) {
i64Data[j] = static_cast<int64_t>(i32Data[j]);
}
} else {
if (tensorData != hostPtr_) {
std::memcpy(tensorData, hostPtr_, unpaddedSize);
}
}
if (deviceOptions_->dumpIOtoFiles) {
DumpToFile(std::string("output_") + std::string(name_) + ".txt", hostPtr_,
unpaddedSize);
}
return NNPI_INF_NO_ERROR;
}
bool NNPIResource::updateResourceDescFromTensorDesc(
NNPIResourceDesc *rDesc, const NNPITensorDesc *tDesc) {
if (tDesc == nullptr || rDesc == nullptr) {
return false;
}
memset(rDesc, 0, sizeof(NNPIResourceDesc));
rDesc->numDims = tDesc->numDims;
for (size_t i = 0; i < rDesc->numDims; i++) {
rDesc->dims[i] = tDesc->dims[i];
}
switch (tDesc->quantParams.precision) {
case NNPI_PRECISION_FLOAT32:
rDesc->dataType = NNPI_INF_PRECISION_FLOAT32;
break;
case NNPI_PRECISION_FLOAT16:
rDesc->dataType = NNPI_INF_PRECISION_FLOAT16;
break;
case NNPI_PRECISION_INT32:
rDesc->dataType = NNPI_INF_PRECISION_INT32;
break;
case NNPI_PRECISION_UINT32:
rDesc->dataType = NNPI_INF_PRECISION_UINT32;
break;
case NNPI_PRECISION_INT8:
rDesc->dataType = NNPI_INF_PRECISION_INT8;
break;
case NNPI_PRECISION_UINT8:
rDesc->dataType = NNPI_INF_PRECISION_UINT8;
break;
case NNPI_PRECISION_BOOLEAN:
rDesc->dataType = NNPI_INF_PRECISION_UINT8;
break;
default:
LOG_AND_RETURN_IF(ERROR, true, "Unhandled precision", false);
break;
}
return true;
}
void NNPIResource::updateDeviceResourceFromTensor(
Tensor *t, std::function<void(Error)> resultCB) {
LOG_AND_FAIL_CALLBACK_IF_NOT(
t != nullptr, "Invalid tensor used to update static input", resultCB);
LOG_AND_FAIL_CALLBACK_IF_NOT(
updateHostResourceFromTensor(t, /* partialTensor */ false,
/* requiresLastElementPadding */ false),
"Invalid Static placeholder", resultCB);
if (deviceOptions_->inferOnDevice) {
const auto sizeFromDesc = CalcDescSize(&desc_);
LOG_AND_FAIL_CALLBACK_IF_NOT(
sizeFromDesc == t->getSizeInBytes(),
"Tensor size " + std::to_string(t->getSizeInBytes()) +
" doesn't match size from description " +
std::to_string(sizeFromDesc) + " for " + name_,
resultCB);
LOG_AND_CALLBACK_NNPI_INF_IF_ERROR(
nnpiDeviceResourceSubLoad(deviceResource_, 0, t->getUnsafePtr(),
t->getSizeInBytes()),
"Failed to execute device resource sub load for " + std::string(name_) +
", size is " + std::to_string(t->getSizeInBytes()) +
" bytes, tensor is " + t->toString(),
resultCB);
}
resultCB(Error::success());
}
bool NNPIResource::updateHostResourceFromTensor(
Tensor *t, bool partialTensor, bool requiresLastElementPadding) {
// Prepare data on the host resource (for ice-ref use int32sTorage).
char *tensorData = t->getUnsafePtr();
const bool downcastInt64 = t->getElementType() == glow::ElemKind::Int64ITy;
size_t paddedSize = t->getSizeInBytes();
size_t unpaddedSize = t->getUnpaddedSizeInBytes();
const bool partialData = (unpaddedSize != paddedSize);
if (usage_ == ResourceUsage::StaticInputResource) {
LOG_AND_RETURN_IF(ERROR, downcastInt64,
"Static placeholder not allowed to be of type Int64",
false);
LOG_AND_RETURN_IF(ERROR, partialData,
"Static placeholders are not allowed to do partial copy",
false);
if (deviceOptions_->inferOnDevice) {
// nothing else to do for static placeholders when running on device
return true;
}
}
if (downcastInt64) {
paddedSize /= 2;
unpaddedSize /= 2;
}
// Copy or convert.
if (downcastInt64) { // Convert
switch (deviceOptions_->avxType) {
case NNPI_AVX_NONE:
convertI64toI32(reinterpret_cast<const int64_t *>(tensorData),
reinterpret_cast<int32_t *>(hostPtr_),
unpaddedSize / sizeof(int32_t));
break;
case NNPI_AVX_AVX512:
convertI64toI32_AVX512(reinterpret_cast<const int64_t *>(tensorData),
reinterpret_cast<int32_t *>(hostPtr_),
unpaddedSize / sizeof(int32_t));
break;
default:
LOG(ERROR) << "Invalid avxType=" << deviceOptions_->avxType;
}
} else if (unpaddedSize) { // Only copy if there is data. Required because
// tensorData cannot be null for memcpy.
if (tensorData != hostPtr_) {
std::memcpy(hostPtr_, tensorData, unpaddedSize);
}
}
// Pad with zeros or last element if needed.
if (partialData && !partialTensor) {
if (!requiresLastElementPadding) {
memset(reinterpret_cast<uint8_t *>(hostPtr_) + unpaddedSize, 0,
paddedSize - unpaddedSize);
} else {
// size of elements in hostPtr_
auto hostElementSize =
downcastInt64 ? sizeof(int32_t) : t->getType().getElementSize();
int numElements = unpaddedSize / hostElementSize;
int totalElements = paddedSize / hostElementSize;
if (hostElementSize == 1) {
std::fill(reinterpret_cast<uint8_t *>(hostPtr_) + numElements,
reinterpret_cast<uint8_t *>(hostPtr_) + totalElements,
reinterpret_cast<const uint8_t *>(hostPtr_)[numElements - 1]);
} else if (hostElementSize == 2) {
std::fill(
reinterpret_cast<uint16_t *>(hostPtr_) + numElements,
reinterpret_cast<uint16_t *>(hostPtr_) + totalElements,
reinterpret_cast<const uint16_t *>(hostPtr_)[numElements - 1]);
} else if (hostElementSize == 4) {
std::fill(
reinterpret_cast<uint32_t *>(hostPtr_) + numElements,
reinterpret_cast<uint32_t *>(hostPtr_) + totalElements,
reinterpret_cast<const uint32_t *>(hostPtr_)[numElements - 1]);
} else if (hostElementSize == 8) {
std::fill(
reinterpret_cast<uint64_t *>(hostPtr_) + numElements,
reinterpret_cast<uint64_t *>(hostPtr_) + totalElements,
reinterpret_cast<const uint64_t *>(hostPtr_)[numElements - 1]);
} else {
LOG(ERROR) << "Invalid Tensor type, padding is unsuccessful";
}
}
partialSize_ = -1;
} else if (partialData) {
partialSize_ = unpaddedSize;
} else {
partialSize_ = -1;
}
return true;
}
std::string NNPIResource::dump() const {
std::stringstream stream;
stream << "NNPIResource: \"" << name_ << '"';
stream << ", DescSize: " << CalcDescSize(&desc_);
stream << ", Usage: " << static_cast<int>(usage_);
stream << ", Adapter: " << pAdapter_;
stream << ", Device: " << device_;
stream << ", DeviceResource: " << deviceResource_;
stream << ", HostResource: " << hostResource_;
stream << ", HostPtr: " << hostPtr_;
stream << ", CopyCommand: " << copyCommand_;
stream << ", CommandListIndex: " << cmdListIdx_;
stream << ", PartialSize: " << partialSize_;
stream << ", ownsDeviceResource: " << ownsDeviceResource_;
stream << ", p2pDevice: " << p2pDevice_;
stream << ", p2pDeviceResource: " << p2pDeviceResource_;
return stream.str();
}
} // namespace runtime
} // namespace glow