Add support of EmbeddingLayerNorm (#4562)

This commit is contained in:
Yufeng Li 2020-07-21 21:43:02 -07:00 committed by GitHub
parent bf78e4d18b
commit 822b23ff2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -356,6 +356,8 @@ class ONNXQuantizer:
new_list += self._handle_activation_ops(node, new_list)
elif node.op_type == 'Attention':
new_list += self._quantize_attention(node, new_list)
elif node.op_type == 'EmbedLayerNormalization':
new_list += self._quantize_embed_layernorm(node, new_list)
else:
new_list += self._handle_other_ops(node, new_list)
@ -1132,6 +1134,15 @@ class ONNXQuantizer:
return nodes
def _quantize_embed_layernorm(self, node, new_nodes_list):
assert (node.op_type == "EmbedLayerNormalization")
(quantized_input_names, zero_point_names, scale_names, nodes) = \
self._quantize_inputs(node, [2, 3, 4], new_nodes_list)
nodes.append(node)
return nodes
def _quantize_convolution_integer_ops(self, node, new_nodes_list):
'''
Used when self.mode is QuantizationMode.IntegerOps.