MCPcopy Create free account
hub / github.com/pytorch/executorch / add_node

Method add_node

backends/qualcomm/debugger/utils.py:89–150  ·  view source on GitHub ↗
(self, node_list, excel_data)

Source from the content-addressed store, hash-verified

87 raise ValueError("Unsupported tensor version")
88
89 def add_node(self, node_list, excel_data):
90 for node_name, tensor in node_list.items():
91 node = tensor["node"]
92 name = node_name
93 data_type = node.dataType
94 tensor_type = node.type
95 dims = node.dimensions
96 quantization_encoding = node.quantizeParams.quantizationEncoding
97 scale = []
98 offset = []
99 if (
100 quantization_encoding
101 == PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_SCALE_OFFSET
102 ):
103 scale.append(node.quantizeParams.scaleOffsetEncoding.scale)
104 offset.append(node.quantizeParams.scaleOffsetEncoding.offset)
105 elif (
106 quantization_encoding
107 == PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET
108 ):
109 for i in range(
110 node.quantizeParams.axisScaleOffsetEncoding.numScaleOffsets
111 ):
112 scale.append(
113 node.quantizeParams.axisScaleOffsetEncoding.scaleOffset[i].scale
114 )
115 offset.append(
116 node.quantizeParams.axisScaleOffsetEncoding.scaleOffset[
117 i
118 ].offset
119 )
120 excel_data.append(
121 {
122 "name": name,
123 "tensor_type": tensor_type,
124 "scale": scale,
125 "offset": offset,
126 }
127 )
128 # Default color for intermediate nodes
129 bg_color = "white"
130 if "input" in node_name or "output" in node_name:
131 bg_color = "lightgreen"
132 elif tensor_type == 4:
133 bg_color = "lightpink"
134 label = f"""<
135 <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
136 <TR><TD BGCOLOR="{bg_color}">name: {name}</TD></TR>
137 <TR><TD BGCOLOR="{bg_color}">data_type: {data_type}</TD></TR>
138 <TR><TD BGCOLOR="{bg_color}">tensor_type: {tensor_type}</TD></TR>
139 <TR><TD BGCOLOR="{bg_color}">dims: {dims}</TD></TR>
140 <TR><TD BGCOLOR="{bg_color}">quantization_encoding: {quantization_encoding}</TD></TR>
141 """
142 label += "</TABLE>>"
143 self.dot.node(
144 node_name,
145 label,
146 shape="box",

Callers 5

get_dot_graphMethod · 0.95
_process_all_nodesMethod · 0.80
export_svgFunction · 0.80

Calls 3

itemsMethod · 0.80
nodeMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected