ZhennanQin commented on a change in pull request #13697: [MKLDNN] Enable signed
int8 support for convolution.
URL: https://github.com/apache/incubator-mxnet/pull/13697#discussion_r244627408
##########
File path: python/mxnet/contrib/quantization.py
##########
@@ -139,18 +136,20 @@ def __init__(self, include_layer=None, logger=None):
def collect(self, name, arr):
"""Callback function for collecting layer output NDArrays."""
- name = py_str(name)
- if self.include_layer is not None and not self.include_layer(name):
- return
- handle = ctypes.cast(arr, NDArrayHandle)
- arr = NDArray(handle, writable=False).copyto(cpu())
- if self.logger is not None:
- self.logger.info("Collecting layer %s output of shape %s" % (name,
arr.shape))
- if name in self.nd_dict:
- self.nd_dict[name].append(arr)
- else:
- self.nd_dict[name] = [arr]
-
+ try:
+ name = py_str(name)
+ if self.include_layer is not None and not self.include_layer(name):
+ return
+ handle = ctypes.cast(arr, NDArrayHandle)
+ arr = NDArray(handle, writable=False).copyto(cpu())
+ if self.logger is not None:
+ self.logger.info("Collecting layer %s output of shape %s" %
(name, arr.shape))
+ if name in self.nd_dict:
+ self.nd_dict[name].append(arr)
+ else:
+ self.nd_dict[name] = [arr]
+ except KeyboardInterrupt:
Review comment:
Adding this is to improve user friendly. Because without this change, you
can't ctrl + c to terminate the quantizaiton script. @KellenSunderland For this
case, do you have any suggested change?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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