toDLPackImpl Class — pytorch Architecture
Architecture documentation for the toDLPackImpl class in DLConvertor.cpp from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/DLConvertor.cpp lines 403–424
template <class T>
T* toDLPackImpl(const Tensor& src) {
auto atDLMTensor = std::make_unique<ATenDLMTensor<T>>();
atDLMTensor->handle = src;
atDLMTensor->tensor.manager_ctx = atDLMTensor.get();
atDLMTensor->tensor.deleter = &deleter<T>;
if (src.device().type() == kMPS) {
atDLMTensor->tensor.dl_tensor.data = src.storage().mutable_data();
atDLMTensor->tensor.dl_tensor.byte_offset = src.storage_offset() * c10::elementSize(src.scalar_type());
} else {
atDLMTensor->tensor.dl_tensor.data = src.data_ptr();
atDLMTensor->tensor.dl_tensor.byte_offset = 0;
}
atDLMTensor->tensor.dl_tensor.device = torchDeviceToDLDevice(src.device());
atDLMTensor->tensor.dl_tensor.ndim = static_cast<int32_t>(src.dim());
atDLMTensor->tensor.dl_tensor.dtype = getDLDataType(src);
atDLMTensor->tensor.dl_tensor.shape = const_cast<int64_t*>(src.sizes().data());
atDLMTensor->tensor.dl_tensor.strides = const_cast<int64_t*>(src.strides().data());
fillVersion(&atDLMTensor->tensor);
return &(atDLMTensor.release()->tensor);
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free