sandeep-krishnamurthy commented on a change in pull request #15245: FP16
Support for C Predict API
URL: https://github.com/apache/incubator-mxnet/pull/15245#discussion_r302831853
##########
File path: amalgamation/python/mxnet_predict.py
##########
@@ -160,10 +249,18 @@ def forward(self, **kwargs):
>>> predictor.forward(data=mydata)
>>> out = predictor.get_output(0)
"""
+ if self.type_dict and len(self.type_dict) != len(kwargs.items()):
+ raise ValueError("number of kwargs should be same as len of
type_dict" \
+ "Please check your forward pass inputs" \
+ "or type_dict passed to Predictor instantiation")
+
for k, v in kwargs.items():
if not isinstance(v, np.ndarray):
raise ValueError("Expect numpy ndarray as input")
- v = np.asarray(v, dtype=np.float32, order='C')
+ if self.type_dict and k in self.type_dict:
+ v = np.asarray(v, dtype=self.type_dict[k], order='C')
+ else:
+ v = np.asarray(v, dtype=np.float32, order='C')
Review comment:
I meant, wherever there are defaults we explicitly call 'np.float32'. In
other places we use a common lookup with _DTYPE_MX_TO_NP. So I was suggesting
if you want to consider moving np.float32 as a default in these
(_DTYPE_MX_TO_NP) look up table so there are no hard coded np.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