shoubhik opened a new issue #16177: How to dump quantized weights from MKLDNN 
as Ndarray
URL: https://github.com/apache/incubator-mxnet/issues/16177
 
 
   Hi,
   I have a use case where i need to debug the weights of Convolution layer 
when quantized by MKLDNN in MXNet 
[here](https://github.com/apache/incubator-mxnet/blob/master/src/operator/subgraph/mkldnn/mkldnn_conv.cc#L189-L190).
 The problem I am facing is that the model saved has the original fp32 weights 
and it is converted to int8 during runtime. When I do try to dump the 
cached_weight_ into a File as NDArray it is computed asynchronously and I get 
an error saying the weight is unavailable. The code I am using is something 
like this
   
   
   ```
   LOG(INFO) << "Writing cached integer weight file";
         char cwd[200];
         getcwd(cwd, sizeof(cwd));
         std::string current_dir(cwd);
         LOG(INFO) << "The current dir is : " << current_dir;
         LOG(INFO) << "Writing qunatized cached weights to file";
         int num_args = 1;
         std::vector<NDArray> data(num_args);
         std::vector<std::string> names(num_args);
         data[0] = cached_weight_;
         names[0] = op_name;
         std::string cached_weight_file_path = current_dir + 
"/quantized-conv-weights/" + op_name;
         std::unique_ptr<dmlc::Stream> 
fo(dmlc::Stream::Create(cached_weight_file_path.c_str(), "w"));
         mxnet::NDArray::Save(fo.get(), data, names);
         LOG(INFO) << "Written weights to " + cached_weight_file_path;
   ```

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


With regards,
Apache Git Services

Reply via email to