Skip to content
Snippets Groups Projects
Commit 7efbb088 authored by auphelia's avatar auphelia
Browse files

[CustomOp] Change calculation for execution slightly in QuantAvgPool2d

parent c0a9f59f
No related branches found
No related tags found
No related merge requests found
......@@ -14,9 +14,9 @@ class QuantAvgPool2d(CustomOp):
return {
"stride": ("i", True, 1),
"kernel": ("i", True, 1),
"ibits": ("s", True, ""),
"obits": ("i", False, 0),
"signed": ("i", False, 0),
"ibits": ("i", True, 1),
"obits": ("i", True, 1),
"signed": ("i", True, 0),
}
def make_shape_compatible_op(self, model):
......@@ -84,11 +84,10 @@ class QuantAvgPool2d(CustomOp):
result_temp = (result_temp[0] * (k * k)).astype(int)
max_value = np.max(result_temp)
max_bit_width = int(max_value).bit_length()
shift_bits = max_bit_width - self.get_nodeattr("obits")
shift_bits = max_bit_width - self.get_nodeattr("obits") + 1
shift_array = np.ones(result_temp.shape, dtype=np.int) * shift_bits
result = np.right_shift(result_temp, shift_array)
context[node.output[0]] = result
context[node.output[0]] = result.astype(np.float32)
def verify_node(self):
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment