(self, original_node)
Replaces a MatMul node with the eight bit equivalent sub-graph.
Replaces a MatMul node with the eight bit equivalent sub-graph.
Replaces a MatMul node with the eight bit equivalent sub - graph .
def eightbitize_mat_mul_node(self, original_node):
    """Replaces a MatMul node with the eight bit equivalent sub-graph."""
    quantized_mat_mul_name = original_node.name + "_eightbit_quantized_mat_mul"
    all_input_names = self.add_eightbit_prologue_nodes(original_node)
    quantized_mat_mul_node = create_node("QuantizedMatMul",
                                         quantized_mat_mul_name,
                                         all_input_names)
    set_attr_dtype(quantized_mat_mul_node, "T1", dtypes.quint8)
    set_attr_dtype(quantized_mat_mul_node, "T2", dtypes.quint8)
    set_attr_dtype(quantized_mat_mul_node, "Toutput", dtypes.qint32)
    copy_attr(quantized_mat_mul_node, "transpose_a",
              original_node.attr["transpose_a"])
    copy_attr(quantized_mat_mul_node, "transpose_b",
              original_node.attr["transpose_b"])
    self.add_output_graph_node(quantized_mat_mul_node)
    quantize_down_name = self.add_quantize_down_nodes(original_node,
                                                      quantized_mat_mul_name)
    self.add_dequantize_result_node(quantize_down_name, original_node.name)
def eightbitize_mat_mul_node ( self , original_node ) : quantized_mat_mul_name = original_node . name + "_eightbit_quantized_mat_mul" all_input_names = self . add_eightbit_prologue_nodes ( original_node ) quantized_mat_mul_node = create_node ( "QuantizedMatMul" , quantized_mat_mul_name , all_input_names ) set_attr_dtype ( quantized_mat_mul_node , "T1" , dtypes . quint8 ) set_attr_dtype ( quantized_mat_mul_node , "T2" , dtypes . quint8 ) set_attr_dtype ( quantized_mat_mul_node , "Toutput" , dtypes . qint32 ) copy_attr ( quantized_mat_mul_node , "transpose_a" , original_node . attr [ "transpose_a" ] ) copy_attr ( quantized_mat_mul_node , "transpose_b" , original_node . attr [ "transpose_b" ] ) self . add_output_graph_node ( quantized_mat_mul_node ) quantize_down_name = self . add_quantize_down_nodes ( original_node , quantized_mat_mul_name ) self . add_dequantize_result_node ( quantize_down_name , original_node . name )