rondogency commented on a change in pull request #17270: [WIP] Dynamic custom
operator GPU support
URL: https://github.com/apache/incubator-mxnet/pull/17270#discussion_r367730326
##########
File path: include/mxnet/lib_api.h
##########
@@ -215,25 +225,43 @@ struct MXTensor {
MXTensor() : data_ptr(NULL), dtype(kUNSET), verID(0) {}
MXTensor(void *data_ptr, const std::vector<int64_t> &shape, MXDType dtype,
- size_t vID)
- : data_ptr(data_ptr), shape(shape), dtype(dtype), verID(vID) {}
+ size_t vID, MXContext mx_ctx)
+ : data_ptr(data_ptr), shape(shape), dtype(dtype), verID(vID), ctx(mx_ctx) {}
/*! \brief populate internal tensor fields */
- void setTensor(void *dptr, MXDType type, const int64_t* dims,
- int ndims, size_t vID) {
- data_ptr = dptr; dtype = type; verID = vID;
+ void setTensor(void *dptr, MXDType type, const int64_t* dims, int ndims,
+ size_t vID, MXContext mx_ctx) {
+ data_ptr = dptr; dtype = type; verID = vID; ctx = mx_ctx;
shape.clear();
for (int j = 0; j < ndims; j++) {
shape.push_back(dims[j]);
}
- setDLTensor();
+ DLDeviceType dltype;
+ if (ctx.dev_type == "cpu")
+ dltype = kDLCPU;
+ else if (ctx.dev_type == "gpu")
+ dltype = kDLGPU;
+ else if (ctx.dev_type == "opencl")
+ dltype = kDLOpenCL;
+ else if (ctx.dev_type == "vulcan")
+ dltype = kDLVulkan;
+ else if (ctx.dev_type == "metal")
+ dltype = kDLMetal;
+ else if (ctx.dev_type == "vpi")
+ dltype = kDLVPI;
+ else if (ctx.dev_type == "rocm")
+ dltype = kDLROCM;
+ else
+ dltype = kDLExtDev;
Review comment:
agree, and for "ext" let's wait for other reviewers
----------------------------------------------------------------
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]
With regards,
Apache Git Services