tqchen commented on a change in pull request #7488:
URL: https://github.com/apache/tvm/pull/7488#discussion_r583167628
##########
File path: src/runtime/minrpc/minrpc_server.h
##########
@@ -209,30 +220,39 @@ class MinRPCServer {
}
void HandleCopyToRemote() {
- uint64_t handle, offset, num_bytes;
- TVMContext ctx;
- DLDataType type_hint;
-
- this->Read(&handle);
- this->Read(&offset);
+ DLTensor* arr = this->ArenaAlloc<DLTensor>(1);
+ uint64_t data_handle;
+ this->Read(&data_handle);
+ arr->data = reinterpret_cast<void*>(data_handle);
+ this->Read(&(arr->ctx));
+ this->Read(&(arr->ndim));
+ this->Read(&(arr->dtype));
+ arr->shape = this->ArenaAlloc<int64_t>(arr->ndim);
+ this->ReadArray(arr->shape, arr->ndim);
+ arr->strides = nullptr;
+ this->Read(&(arr->byte_offset));
+ uint64_t num_bytes;
this->Read(&num_bytes);
- this->Read(&ctx);
- this->Read(&type_hint);
- int call_ecode = 0;
- if (ctx.device_type == kDLCPU) {
- uint8_t* dptr = reinterpret_cast<uint8_t*>(handle) + offset;
+ int call_ecode = 0;
+ if (arr->ctx.device_type == kDLCPU) {
+ uint8_t* dptr = reinterpret_cast<uint8_t*>(data_handle) +
arr->byte_offset;
this->ReadArray(dptr, num_bytes);
} else {
uint8_t* temp_data = this->ArenaAlloc<uint8_t>(num_bytes);
this->ReadArray(temp_data, num_bytes);
-
- call_ecode =
- TVMDeviceCopyDataFromTo(temp_data, 0,
reinterpret_cast<void*>(handle), offset, num_bytes,
- DLContext{kDLCPU, 0}, ctx, type_hint,
nullptr);
+ DLTensor temp;
+ temp.data = temp_data;
+ temp.ctx = DLContext{kDLCPU, 0};
+ temp.ndim = arr->ndim;
+ temp.dtype = arr->dtype;
+ temp.shape = arr->shape;
+ temp.strides = nullptr;
+ temp.byte_offset = 0;
Review comment:
Because most cases we have to pass in most positional arguments. If
there are a lot of defaults then i agree a helper would be good, directly
constructing also has the benefit of being explicit about field name like kw
arguments.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]