wuxun-zhang commented on a change in pull request #15164: [C++] Improve 
inference script to support benchmark on Imagenet
URL: https://github.com/apache/incubator-mxnet/pull/15164#discussion_r294710349
 
 

 ##########
 File path: cpp-package/include/mxnet-cpp/initializer.h
 ##########
 @@ -91,6 +100,14 @@ class Initializer {
   virtual void InitGamma(NDArray* arr) { (*arr) = 1.0f; }
   virtual void InitBeta(NDArray* arr) { (*arr) = 0.0f; }
   virtual void InitWeight(NDArray* arr) {}
+  virtual void InitQuantizedWeight(NDArray* arr) {
+    std::default_random_engine generator;
+    std::uniform_int_distribution<int32_t> _val(-127, 127);
+    (*arr) = static_cast<int8_t>(_val(generator));
+  }
+  virtual void InitQuantizedBias(NDArray* arr) {
+    (*arr) = (int8_t)0;
+  }
 
 Review comment:
   Thanks for your comments. Now `operator=` does not support int8. If I add 
support for int8, there will be ambiguity due to implicit type conversion. For 
example, when I try to use `(*arr) = 0` to initialize a NDArray, the compiler 
doesn't know which `operator=` function should be called. So, as a work-around 
method, I will assign a float value to a int8 NDArray temporarily.

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