mxnet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-mxnet] samskalicky commented on a change in pull request #15921: dynamic custom operator support
Date Fri, 18 Oct 2019 04:48:14 GMT
samskalicky commented on a change in pull request #15921: dynamic custom operator support
URL: https://github.com/apache/incubator-mxnet/pull/15921#discussion_r336319079
 
 

 ##########
 File path: include/mxnet/lib_api.h
 ##########
 @@ -63,7 +211,46 @@ struct MXTensor {
   MXTensor() : data_ptr(NULL) {}
 
   MXTensor(void *data_ptr, const std::vector<int64_t> &shape, MXDType dtype)
-  : data_ptr(data_ptr), shape(shape), dtype(dtype) {}
+  : data_ptr(data_ptr), shape(shape), dtype(dtype) {
+    dltensor.data = data_ptr;
+    dltensor.ctx.device_type = kDLCPU;
+    dltensor.ctx.device_id = 0;
+    dltensor.ndim = shape.size();
+    dltensor.shape = const_cast<int64_t*>(shape.data());
+    dltensor.strides = NULL;
+    dltensor.byte_offset = 0;
+    dltensor.dtype.lanes = 1;
+    switch(dtype) {
+    case kFloat32:
+      dltensor.dtype.code = kDLFloat;
+      dltensor.dtype.bits = 32;
+      break;
+    case kFloat64:
+      dltensor.dtype.code = kDLFloat;
+      dltensor.dtype.bits = 64;
+      break;
+    case kFloat16:
+      dltensor.dtype.code = kDLFloat;
+      dltensor.dtype.bits = 16;
+      break;
+    case kUint8:
+      dltensor.dtype.code = kDLUInt;
+      dltensor.dtype.bits = 8;
+      break;
+    case kInt32:
+      dltensor.dtype.code = kDLInt;
+      dltensor.dtype.bits = 32;
+      break;
+    case kInt8:
+      dltensor.dtype.code = kDLInt;
+      dltensor.dtype.bits = 8;
+      break;
+    case kInt64:
+      dltensor.dtype.code = kDLInt;
+      dltensor.dtype.bits = 64;
 
 Review comment:
   Done, changed to:
   https://github.com/apache/incubator-mxnet/blob/5761891d039c49e34ab1da86ed802239d83e545d/include/mxnet/lib_api.h#L256-L258

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message