guanxinq commented on a change in pull request #17569: Adding sparse support to 
MXTensor for custom operators
URL: https://github.com/apache/incubator-mxnet/pull/17569#discussion_r392462090
 
 

 ##########
 File path: include/mxnet/lib_api.h
 ##########
 @@ -1091,6 +1187,43 @@ extern "C" {
     return retval;
   }
 
+   /*! \brief returns status of calling inferSType function for operator from 
library */
+#if defined(_WIN32) || defined(_WIN64) || defined(__WINDOWS__)
+  __declspec(dllexport) int __cdecl
+#else
+  int
+#endif
+   _opCallInferSType(inferSType_t inferSType, const char* const* keys,
+                   const char* const* vals, int num,
+                   int* instypes, int num_in, int* outstypes, int num_out) {
+    // create map of attributes from list
+    std::map<std::string, std::string> attrs;
+    for (int i = 0; i < num; i++) {
+      attrs[std::string(keys[i])] = std::string(vals[i]);
+    }
+
+    // create a vector of types for inputs
+    std::vector<int> in_stypes(num_in);
+    for (int i = 0; i < num_in; i++) {
+      in_stypes[i] = instypes[i];
+    }
+
+    // create a vector of types for outputs
+    std::vector<int> out_stypes(num_out, -1);
+
+    int retval = inferSType(attrs, in_stypes, out_stypes);
+
+    if (!retval)
+      return retval;
+
+    // copy output types
+    for (int i = 0; i < num_out; i++) {
+      outstypes[i] = out_stypes[i];
 
 Review comment:
   STORAGE_TYPE_ASSIGN_CHECK() in line 659 of c_api.cc will check it.

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