samskalicky commented on a change in pull request #17270: Dynamic custom 
operator GPU support
URL: https://github.com/apache/incubator-mxnet/pull/17270#discussion_r369386321
 
 

 ##########
 File path: include/mxnet/lib_api.h
 ##########
 @@ -1056,26 +1171,30 @@ extern "C" {
   int
 #endif
   _opCallFStatefulCompute(int is_forward, void* state_op,
-                          const int64_t** inshapes, int* indims,
-                          void** indata, int* intypes, size_t* inIDs, int 
num_in,
-                          const int64_t** outshapes, int* outdims,
-                          void** outdata, int* outtypes, size_t* outIDs, int 
num_out,
-                          xpu_malloc_t cpu_malloc, void* cpu_alloc) {
+                          const int64_t** inshapes, int* indims, void** 
indata, int* intypes,
+                          size_t* inIDs, const char** indev_type, int* 
indev_id, int num_in,
+                          const int64_t** outshapes, int* outdims, void** 
outdata, int* outtypes,
+                          size_t* outIDs, const char** outdev_type, int* 
outdev_id, int num_out,
+                          xpu_malloc_t cpu_malloc, void* cpu_alloc,
+                          xpu_malloc_t gpu_malloc, void* gpu_alloc, void* 
stream) {
     // create a vector of tensors for inputs
     std::vector<MXTensor> inputs(num_in);
     for (int i = 0; i < num_in; i++) {
-      inputs[i].setTensor(indata[i], (MXDType)intypes[i], inshapes[i], 
indims[i], inIDs[i]);
+      inputs[i].setTensor(indata[i], (MXDType)intypes[i], inshapes[i], 
indims[i],
+                          inIDs[i], {indev_type[i], indev_id[i]});
     }
 
     // create a vector of tensors for outputs
     std::vector<MXTensor> outputs(num_out);
     for (int i = 0; i < num_out; i++) {
       outputs[i].setTensor(outdata[i], (MXDType)outtypes[i], outshapes[i], 
outdims[i],
-                           outIDs[i]);
+                           outIDs[i], {outdev_type[i], outdev_id[i]});
     }
-    OpResource res(cpu_malloc, cpu_alloc);
+
+    OpResource res(cpu_malloc, cpu_alloc, gpu_malloc, gpu_alloc, stream);
+
     CustomStatefulOp* op_ptr = reinterpret_cast<CustomStatefulOp*>(state_op);
-    if (is_forward) {
+    if (is_forward == 1) {
 
 Review comment:
   the equal comparison is not necessary since a you're passing either a 1 or a 
0 in c_api.cc and `if(0)` evaluates to false

----------------------------------------------------------------
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

Reply via email to