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_r392525710
##########
File path: src/c_api/c_api.cc
##########
@@ -572,12 +645,30 @@ int MXLoadLib(const char *path) {
DispatchMode* dispatch_mode,
std::vector<int>* in_stypes,
std::vector<int>* out_stypes) {
- // TODO(ziyimu): remove this dense enforce check after supporting sparse
tensor
- CHECK(mxnet::common::ContainsOnlyStorage(*in_stypes,
mxnet::kDefaultStorage))
- << "Error input tensors are not dense for custom operator '" << name_str
<< "'";
- // set outputs as dense
- return op::storage_type_assign(out_stypes, mxnet::kDefaultStorage,
- dispatch_mode, DispatchMode::kFComputeEx);
+ // convert attributes to vector of char*
+ std::vector<const char*> attr_keys, attr_vals;
+ for (auto kv : attrs.dict) {
+ attr_keys.push_back(kv.first.c_str());
+ attr_vals.push_back(kv.second.c_str());
+ }
+ // copy input types from in_stype
+ std::vector<int> instypes(*in_stypes);
+
+ // output types will be populated by inferType function
+ std::vector<int> outstypes(out_stypes->size());
+
+ CHECK(callInferSType(stype_fp, attr_keys.data(), attr_vals.data(),
attr_keys.size(),
Review comment:
Do we have to do so? Just like the InferType function, do we need to have
default implementation for float32?
----------------------------------------------------------------
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