blob: a43aac2a9ce76a37dc16a550c6d2fbd8f92c5e4e [file] [log] [blame]
Fredrik Svedberg33c01e62023-02-13 11:32:12 +01001# SPDX-FileCopyrightText: Copyright 2020-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
Tim Hall79d07d22020-04-27 18:20:16 +01002#
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the License); you may
6# not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an AS IS BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
Rickard Bolinbc6ee582022-11-04 08:24:29 +000016#
Tim Hall79d07d22020-04-27 18:20:16 +010017# Description:
18# Neural network graph classes and enums.
19# Pass - A packed pass containing one or more Operations.
20# CascadedPass - A scheduled pass containing one or more Passes, as well as a scheduling strategy and block
21# configurations.
22# Subgraph - Holds a neural network subgraph, pointing at Tensors, Operations, Passes, and CascadedPasses.
23# Graph - A full neural network graph with one or more Subgraphs.
Tim Hall79d07d22020-04-27 18:20:16 +010024import enum
patrik.gustavssoneeb85152020-12-21 17:10:40 +000025from typing import List
Tim Hall79d07d22020-04-27 18:20:16 +010026
Louis Verhaardaee5d752020-09-30 09:01:52 +020027from .operation import Op
patrik.gustavssoneeb85152020-12-21 17:10:40 +000028from .shape4d import Shape4D
Louis Verhaardaee5d752020-09-30 09:01:52 +020029
Tim Hall79d07d22020-04-27 18:20:16 +010030
31class PassPlacement(enum.Enum):
32 Unknown = 0
33 Cpu = 1
34 Npu = 2
35 MemoryOnly = 3
36 StartupInit = 4
37
38
39class TensorAllocator(enum.Enum):
40 LinearAlloc = 1
41 Greedy = 2
Louis Verhaardd7002522021-01-20 17:23:54 +010042 HillClimb = 3
Tim Hall79d07d22020-04-27 18:20:16 +010043
44 def __str__(self):
45 return self.name
46
47
Patrik Gustavsson8f1f9aa2021-06-28 07:41:58 +020048class NetworkType(enum.Enum):
49 TFLite = 1
50 TOSA = 2
51
52
Tim Hall79d07d22020-04-27 18:20:16 +010053class Pass:
54 def __init__(self, name, placement, is_element_wise, npu_block_type):
55 self.inputs = []
56 self.intermediates = []
57 self.outputs = []
58 self.ops = []
59 self.primary_op = None
60 self.ifm_tensor = None
61 self.ifm2_tensor = None
62 self.ofm_tensor = None
63 self.weight_tensor = None
64 self.scale_tensor = None
Fredrik Svedberga0c36242020-06-03 15:43:31 +020065 self.lut_tensor = None
Tim Hall79d07d22020-04-27 18:20:16 +010066 self.name = name
67 self.cascade = None
68 self.placement = placement
patrik.gustavssoneeb85152020-12-21 17:10:40 +000069 self.ifm_shapes: List[Shape4D] = []
70 self.ofm_shapes: List[Shape4D] = []
Tim Hall79d07d22020-04-27 18:20:16 +010071
72 # TODO: rename is_element_wise because it is not the same as an ElementWise operator. It is used by the tensor
73 # allocation and requires that the OFM and IFM has the exact same address. Essentially complete overlap.
74 self.is_element_wise = is_element_wise
75 self.npu_block_type = npu_block_type
76 self.block_config = None # will be filled in by scheduler
77 self.shared_buffer = None # will be filled in by scheduler
Tim Halld8339a72021-05-27 18:49:40 +010078 self.scheduling_info = None # will be filled in by scheduler
Tim Hall79d07d22020-04-27 18:20:16 +010079
80 self.predecessors = []
81 self.successors = []
82
83 def __str__(self):
84 return "<nng.Pass '%s', %s, ops=%s>" % (self.name, self.placement, [op.type for op in self.ops])
85
86 __repr__ = __str__
87
88 def get_primary_op_ifm_weights(self):
89 if not self.primary_op:
90 return None, None
91 return self.primary_op.get_ifm_ifm2_weights_ofm()[::2]
92
93 def get_primary_op_ifm_ifm2_weights_ofm(self):
94 if not self.primary_op:
95 return None, None, None, None
96 return self.primary_op.get_ifm_ifm2_weights_ofm()
97
98 def get_primary_op_ifm_weights_biases_ofm(self):
99 if not self.primary_op:
100 return None, None, None, None
101 return self.primary_op.get_ifm_weights_biases_ofm()
102
Fredrik Svedberga0c36242020-06-03 15:43:31 +0200103 def get_primary_op_lut(self):
104 if not self.primary_op:
105 return None
106 return self.primary_op.activation_lut
107
Tim Hall79d07d22020-04-27 18:20:16 +0100108
109class SchedulingStrategy(enum.Enum):
110 Unknown = -1
111 IfmStream = 0
112 WeightStream = 1
113
114
115class SchedulerRewrite(enum.Enum):
116 Nop = 0
117 ChangeTensorSubPurpose = 1
118
119
120class CascadedPass:
121 def __init__(self, name, strat, inputs, intermediates, outputs, passes, placement, is_element_wise):
122 self.name = name
123 self.strategy = strat
124 self.inputs = inputs
125 self.intermediates = intermediates
126 self.outputs = outputs
127 self.passes = passes
128 self.placement = placement
129 self.is_element_wise = is_element_wise
130
131 self.predecessors = []
132 self.successors = []
Tim Halld8339a72021-05-27 18:49:40 +0100133 self.sram_used = 0
Jonas Ohlsson845e2322022-03-01 12:39:55 +0100134 self.time = 0
Tim Hall79d07d22020-04-27 18:20:16 +0100135
136 def __str__(self):
137 return "<nng.CascadedPass strategy=%s x %s '%s', passes=%s, block_configs=%s>" % (
138 self.strategy,
139 len(self.passes),
140 self.name,
141 [ps.name for ps in self.passes],
142 [ps.block_config for ps in self.passes],
143 )
144
145 __repr__ = __str__
146
147
148class Subgraph:
149 def __init__(self, name="<unnamed>", placement=PassPlacement.Cpu):
150 self.output_tensors = []
151 self.input_tensors = []
Johan Alfven9070f0f2023-02-07 13:01:03 +0100152 # Preserve the original input order
153 self.original_inputs = []
154 # Attach virtual outputs to resource variables op
155 # in order to be able to traverse the graph correctly
156 self.virtual_outputs = []
Tim Hall79d07d22020-04-27 18:20:16 +0100157 self.passes = []
158 self.cascaded_passes = []
159 self.name = name
160 self.high_level_command_stream = []
161 self.placement = placement
162 self.command_stream_tensor = None
163 self.flash_tensor = None
Louis Verhaard0b9c9a32020-09-15 14:05:38 +0200164 # Scratch information locally used in the scheduler
Tim Halld8339a72021-05-27 18:49:40 +0100165 self.schedule = None
166 self.sched_ops = []
167
erik.andersson@arm.comad45f792021-02-03 10:20:16 +0100168 self.generated_stream_id = None
Tim Hall79d07d22020-04-27 18:20:16 +0100169
170 self.memory_used = {}
Patrik Gustavssoneca2e952020-05-27 09:15:11 +0200171 self.memory_used_per_type = {}
Tim Hall79d07d22020-04-27 18:20:16 +0100172
173 def __str__(self):
174 return "<nng.Subgraph '%s', n_passes=%d, n_cascaded_passes=%d>" % (
175 self.name,
176 len(self.passes),
177 len(self.cascaded_passes),
178 )
179
180 __repr__ = __str__
181
182 def update_consumers(self):
183 visit_op_set = set()
184 visit_tensor_set = set()
185 self.input_tensors = []
186
187 print_visit = False
188
189 def visit_op(op):
190 if op in visit_op_set:
191 return
192
193 visit_op_set.add(op)
194 for inp in op.inputs:
Jacob Bohlin67e0d8f2020-08-20 10:53:02 +0200195 if not inp:
196 continue
Tim Hall79d07d22020-04-27 18:20:16 +0100197 if print_visit:
198 print(inp, "adding consumer", op)
199 visit_tensor(inp)
200 inp.consumer_list.append(op)
201
Michael McGeaghf3e3ad72020-12-02 12:39:03 +0000202 if op.type in (Op.Placeholder, Op.SubgraphInput):
Tim Hall79d07d22020-04-27 18:20:16 +0100203 assert len(op.outputs) == 1
Fredrik Svedberg33c01e62023-02-13 11:32:12 +0100204 if not op.outputs[0].is_variable:
205 self.input_tensors.append(op.outputs[0])
Tim Hall79d07d22020-04-27 18:20:16 +0100206
207 for out in op.outputs:
208 if out not in visit_tensor_set:
209 out.consumer_list = [] # reset unvisited output, just in case
210
211 def visit_tensor(tens):
212 if tens in visit_tensor_set:
213 return
214 visit_tensor_set.add(tens)
215 tens.consumer_list = []
216 for op in tens.ops:
217 visit_op(op)
218
219 for ps in self.passes:
220 for tens in ps.outputs + ps.inputs:
Jacob Bohlin67e0d8f2020-08-20 10:53:02 +0200221 if not tens:
222 continue
Tim Hall79d07d22020-04-27 18:20:16 +0100223 tens.consumer_list = [] # reset unvisited tensors to start with
224
225 for tens in self.output_tensors:
226 visit_tensor(tens)
227 tens.consumer_list.append(None) # special op to indicate that the graph consumes the result
228
229 print_visit = True
230 for ps in self.passes:
231 for op in ps.ops:
232 visit_op(op)
233 for tens in ps.inputs:
234 visit_tensor(tens)
235
236 def build_pass_links(self):
237 for idx, ps in enumerate(self.passes):
238 ps.time = 2 * idx
239 ps.predecessors = []
240 ps.successors = []
241
242 for ps in self.passes:
243 for tens in ps.inputs:
244 for op in tens.ops:
245 pred_pass = op.scheduled_pass
246 assert pred_pass.time < ps.time
247 if ps not in pred_pass.successors:
248 pred_pass.successors.append(ps)
249
250 if pred_pass not in ps.predecessors:
251 ps.predecessors.append(pred_pass)
252
253 assert tens in pred_pass.outputs
254
255 def build_pass_dag_predecessors(self):
256 for ps in self.passes:
257 ps.dag_predecessors = []
258
259 class State(enum.Enum):
260 NotVisited = 0
261 BeingVisited = 1
262 Visited = 2
263
264 pass_visit_dict = {}
265
266 def visit_pass(ps):
267 state = pass_visit_dict.get(ps, State.NotVisited)
268 if state == State.Visited:
269 return True
270 elif state == State.BeingVisited:
271 return False # this is a loop, need to remove this link
272 elif state == State.NotVisited:
273 pass_visit_dict[ps] = State.BeingVisited
274
275 ps.dag_predecessors = []
276 for pred in ps.predecessors:
277 if visit_pass(pred):
278 ps.dag_predecessors.append(pred)
279
280 pass_visit_dict[ps] = State.Visited
281 return True
282
283 for ps in self.passes:
284 if not ps.successors:
285 visit_pass(ps)
286
287 def build_cascaded_pass_links(self):
288 for cps in self.cascaded_passes:
289 cps.predecessors = []
290 cps.successors = []
291
292 for cps in self.cascaded_passes:
293 for tens in cps.inputs:
294 for op in tens.ops:
295 pred_cpass = op.scheduled_pass.cascade
296 if cps not in pred_cpass.successors:
297 pred_cpass.successors.append(cps)
298
299 if pred_cpass not in cps.predecessors:
300 cps.predecessors.append(pred_cpass)
301
302 assert tens in pred_cpass.outputs
303
304 def refresh_after_modification(self):
305 self.update_consumers()
306
307 def prune_startup_init_pass(self):
308 assert len(self.passes) >= 1
309 ps = self.passes[0]
310 assert ps.placement == PassPlacement.StartupInit
311
312 ps.outputs = [out_tens for out_tens in ps.outputs if len(out_tens.consumers()) > 0]
313 ps.ops = [op for op in ps.ops if op.outputs[0] in ps.outputs]
314
315 def get_all_ops(self):
316 all_ops = []
317 visit_op_set = set()
318 visit_tensor_set = set()
319
320 def visit_op(op):
321 if op in visit_op_set:
322 return
323 visit_op_set.add(op)
324 for inp in op.inputs:
325 visit_tensor(inp)
326
327 all_ops.append(op)
328
329 def visit_tensor(tens):
Andreas Nevalainene1cc3de2020-09-08 15:31:02 +0200330 if tens is None or tens in visit_tensor_set:
Tim Hall79d07d22020-04-27 18:20:16 +0100331 return
332 visit_tensor_set.add(tens)
333 for op in tens.ops:
334 visit_op(op)
335
336 for tens in self.output_tensors:
337 visit_tensor(tens)
338
339 return all_ops
340
341 def print_operators(self):
Michael McGeagh775e3962020-07-28 11:44:22 +0100342 print("print_operators()", self.name)
Tim Hall79d07d22020-04-27 18:20:16 +0100343 all_ops = self.get_all_ops()
344 unique_ops = []
Tim Hall79d07d22020-04-27 18:20:16 +0100345 for op in all_ops:
Michael McGeaghf3e3ad72020-12-02 12:39:03 +0000346 if op.type in (Op.Const, Op.Identity, Op.Placeholder):
Tim Hall79d07d22020-04-27 18:20:16 +0100347 continue
348
Louis Verhaardaee5d752020-09-30 09:01:52 +0200349 attrs = op.attrs.copy()
350 if op.type in (Op.Conv2D, Op.Conv2DBias, Op.DepthwiseConv2DBias):
Tim Hall79d07d22020-04-27 18:20:16 +0100351 kshape = op.inputs[1].shape
352 attrs["kshape"] = [kshape[0], kshape[1]]
Louis Verhaardaee5d752020-09-30 09:01:52 +0200353 attrs["type"] = op.type.name
Tim Hall79d07d22020-04-27 18:20:16 +0100354 attrs.pop("use_cudnn_on_gpu", None)
Fredrik Svedberg16343052021-04-16 14:36:22 +0200355 custom_options = attrs.pop("custom_options", None)
Tim Hall79d07d22020-04-27 18:20:16 +0100356 if attrs not in unique_ops:
357 unique_ops.append(attrs)
358 # print attributes in human readable format
359 a = attrs.copy()
Fredrik Svedberg16343052021-04-16 14:36:22 +0200360 if custom_options is not None:
361 a["custom_options"] = custom_options
Tim Hall79d07d22020-04-27 18:20:16 +0100362 s = a.pop("type")
363 data_format = a.pop("data_format", None)
364 if data_format and data_format != b"NHWC":
365 s += " " + str(data_format)
366 t = a.pop("T", None)
367 if t:
368 s += " " + str(t)[9:-2]
369 srct = a.pop("SrcT", None)
370 if srct:
371 s += " " + str(srct)[9:-2]
372 dstt = a.pop("DstT", None)
373 if dstt:
374 s += "->" + str(dstt)[9:-2]
375 print(s + " " + str(a))
376
Fredrik Svedbergc875aa62021-05-06 09:53:31 +0200377 def print_graph(self, label=None):
378 if label:
379 print(f"\n[ {label} ]")
Michael McGeagh775e3962020-07-28 11:44:22 +0100380 print("print_graph()", self.name)
Tim Hall79d07d22020-04-27 18:20:16 +0100381 all_ops = self.get_all_ops()
382 for idx, op in enumerate(all_ops):
383 print(idx, op.type, op.name)
384
385 def print_graph_with_tensors(self):
Michael McGeagh775e3962020-07-28 11:44:22 +0100386 print("print_graph_with_tensors()", self.name)
Tim Hall79d07d22020-04-27 18:20:16 +0100387 all_ops = self.get_all_ops()
388 for idx, op in enumerate(all_ops):
389 print(idx, op.type, op.name)
390 for idx, tens in enumerate(op.inputs):
Fredrik Svedbergb3d941e2021-10-13 14:06:03 +0200391 if tens:
392 print(
393 f" Input {idx:02d}"
394 f" {tens.purpose.name:>20} {tens.mem_area.name:>20} {tens.mem_type.name:>20} {tens}"
395 )
396 else:
397 print(f" Input {idx:02d} {'-':>20} {'-':>20} {'-':>20} {tens}")
Tim Hall79d07d22020-04-27 18:20:16 +0100398 for idx, tens in enumerate(op.outputs):
Patrik Gustavssoneca2e952020-05-27 09:15:11 +0200399 print(
Fredrik Svedbergb3d941e2021-10-13 14:06:03 +0200400 f" Output {idx:02d}"
401 f" {tens.purpose.name:>20} {tens.mem_area.name:>20} {tens.mem_type.name:>20} {tens}"
Patrik Gustavssoneca2e952020-05-27 09:15:11 +0200402 )
Tim Hall79d07d22020-04-27 18:20:16 +0100403 print()
404
405 def print_graph_with_tensor_quantization(self):
Michael McGeagh775e3962020-07-28 11:44:22 +0100406 print("print_graph_with_tensor_quantization()", self.name)
Tim Hall79d07d22020-04-27 18:20:16 +0100407 all_ops = self.get_all_ops()
408 for idx, op in enumerate(all_ops):
409 print(idx, op.type, op.name)
410 for idx, tens in enumerate(op.inputs):
Fredrik Svedbergb3d941e2021-10-13 14:06:03 +0200411 if tens:
412 q = tens.quantization
413 if q is None:
414 print(f" Input {idx:02d} {tens.dtype!s:>10} NO QUANTIZATION INFO {tens.name}")
415 else:
416 print(
417 f" Input {idx:02d} {tens.dtype!s:>10}"
418 f" min={q.min} max={q.max} scale={q.scale_f32!s} zero_point={q.zero_point} {tens.name}"
419 )
Tim Hall79d07d22020-04-27 18:20:16 +0100420 else:
Fredrik Svedbergb3d941e2021-10-13 14:06:03 +0200421 print(f" Input {idx:02d} {'-':>10} {tens}")
Tim Hall79d07d22020-04-27 18:20:16 +0100422 for idx, tens in enumerate(op.outputs):
423 q = tens.quantization
424 if q is None:
Fredrik Svedbergb3d941e2021-10-13 14:06:03 +0200425 print(f" Output {idx:02d} {tens.dtype!s:>10} NO QUANTIZATION INFO {tens.name}")
Tim Hall79d07d22020-04-27 18:20:16 +0100426 else:
427 print(
Fredrik Svedbergb3d941e2021-10-13 14:06:03 +0200428 f" Output {idx:02d} {tens.dtype!s:>10}"
429 f" min={q.min} max={q.max} scale={q.scale_f32!s} zero_point={q.zero_point} {tens.name}"
Tim Hall79d07d22020-04-27 18:20:16 +0100430 )
431 print()
432
433 def print_passes(self):
Michael McGeagh775e3962020-07-28 11:44:22 +0100434 print("print_passes()", self.name)
Tim Hall79d07d22020-04-27 18:20:16 +0100435 for idx, ps in enumerate(self.passes):
436 print("%03d %s" % (idx * 2, ps))
437
438 def print_passes_with_tensors(self):
Michael McGeagh775e3962020-07-28 11:44:22 +0100439 print("print_passes_with_tensors()", self.name)
Tim Hall79d07d22020-04-27 18:20:16 +0100440 for idx, ps in enumerate(self.passes):
441 print("%3d %s" % (idx * 2, ps))
442 for idx, tens in enumerate(ps.inputs):
443 print(
444 " Input %2d %-15s %-15s %-15s %s"
445 % (idx, tens.purpose.name, tens.mem_area.name, tens.format.name, tens.name)
446 )
447 for idx, tens in enumerate(ps.intermediates):
448 print(
449 " Intermediate %2d %-15s %-15s %-15s %s"
450 % (idx, tens.purpose.name, tens.mem_area.name, tens.format.name, tens.name)
451 )
452 for idx, tens in enumerate(ps.outputs):
453 print(
454 " Output %2d %-15s %-15s %-15s %s"
455 % (idx, tens.purpose.name, tens.mem_area.name, tens.format.name, tens.name)
456 )
457 print()
458
459 def print_cascaded_passes(self):
Michael McGeagh775e3962020-07-28 11:44:22 +0100460 print("print_cascaded_passes()", self.name)
Tim Hall79d07d22020-04-27 18:20:16 +0100461 for idx, ps in enumerate(self.cascaded_passes):
462 print("%3d %s SRAM used %.1f KB" % (idx * 2, ps, ps.sram_used / 1024))
463
464 def print_cascaded_passes_with_tensors(self):
Michael McGeagh775e3962020-07-28 11:44:22 +0100465 print("print_cascaded_passes_with_tensors()", self.name)
Tim Hall79d07d22020-04-27 18:20:16 +0100466 for idx, ps in enumerate(self.cascaded_passes):
467 print("%3d %s SRAM used %.1f KB" % (idx * 2, ps, ps.sram_used / 1024))
468 for idx, tens in enumerate(ps.inputs):
469 print(
470 " Input %2d %-15s %-15s %-15s %s"
471 % (idx, tens.purpose.name, tens.mem_area.name, tens.format.name, tens.name)
472 )
473 for idx, tens in enumerate(ps.intermediates):
474 print(
475 " Intermediate %2d %-15s %-15s %-15s %s"
476 % (idx, tens.purpose.name, tens.mem_area.name, tens.format.name, tens.name)
477 )
478 for idx, tens in enumerate(ps.outputs):
479 print(
480 " Output %2d %-15s %-15s %-15s %s"
481 % (idx, tens.purpose.name, tens.mem_area.name, tens.format.name, tens.name)
482 )
483 print()
484
485 def print_cascaded_passes_with_tensor_sizes(self):
Michael McGeagh775e3962020-07-28 11:44:22 +0100486 print("print_cascaded_passes_with_tensor_sizes()", self.name)
Tim Hall79d07d22020-04-27 18:20:16 +0100487 for idx, ps in enumerate(self.cascaded_passes):
488 print("%3d %s SRAM used %.1f KB" % (idx * 2, ps, ps.sram_used / 1024))
489 for idx, tens in enumerate(ps.inputs):
490 print(
491 " Input %2d %7.1f KB %-24s %-15s %-15s %-20s %s"
492 % (
493 idx,
494 tens.storage_size() / 1024,
495 tens.storage_shape,
496 tens.mem_area.name,
497 tens.purpose.name,
498 tens.format.name,
499 tens.name,
500 )
501 )
502 for idx, tens in enumerate(ps.intermediates):
503 print(
504 " Intermediate %2d %7.1f KB %-24s %-15s %-15s %-20s %s"
505 % (
506 idx,
507 tens.storage_size() / 1024,
508 tens.storage_shape,
509 tens.mem_area.name,
510 tens.purpose.name,
511 tens.format.name,
512 tens.name,
513 )
514 )
515 for idx, tens in enumerate(ps.outputs):
516 print(
517 " Output %2d %7.1f KB %-24s %-15s %-15s %-20s %s"
518 % (
519 idx,
520 tens.storage_size() / 1024,
521 tens.storage_shape,
522 tens.mem_area.name,
523 tens.purpose.name,
524 tens.format.name,
525 tens.name,
526 )
527 )
528 print()
529
530 def print_high_level_command_stream(self):
Michael McGeagh775e3962020-07-28 11:44:22 +0100531 print("print_high_level_command_stream()", self.name)
Tim Hall79d07d22020-04-27 18:20:16 +0100532 for idx, cmd in enumerate(self.high_level_command_stream):
533 print("%3d %s" % (idx, cmd))
534
535
536class Graph:
537 def __init__(self, name="<unnamed>", batch_size=1):
538 self.name = name
539 self.batch_size = batch_size
540 self.subgraphs = []
Michael McGeagh22f74e12020-08-07 16:21:03 +0100541 self.metadata = []
Tim Hall79d07d22020-04-27 18:20:16 +0100542 self.memory_used = {}
Diqing Zhongdb5124c2021-01-11 12:52:48 +0100543 self.total_original_weights = 0
Fredrik Svedbergf5c07c42021-04-23 14:36:42 +0200544 self.total_npu_encoded_weights = 0
Louis Verhaard3c07c972020-05-07 08:12:58 +0200545 self.weight_cache = None # See CompressedWeightCache
Jonas Ohlsson845e2322022-03-01 12:39:55 +0100546 self.bandwidths = 0
547 self.macs = 0
548 self.cycles = 0
Tim Hall79d07d22020-04-27 18:20:16 +0100549
550 def get_root_subgraph(self):
551 return self.subgraphs[0]
552
553 def prune_startup_init_pass(self):
554 for sg in self.subgraphs:
555 sg.prune_startup_init_pass()
556
557 def update_consumers(self):
558 for sg in self.subgraphs:
559 sg.update_consumers()
560
561 def refresh_after_modification(self):
562 for sg in self.subgraphs:
563 sg.refresh_after_modification()
564
565 def print_operators(self):
566 for sg in self.subgraphs:
567 sg.print_operators()
568
Fredrik Svedbergc875aa62021-05-06 09:53:31 +0200569 def print_graph(self, label=None):
Tim Hall79d07d22020-04-27 18:20:16 +0100570 for sg in self.subgraphs:
Fredrik Svedbergc875aa62021-05-06 09:53:31 +0200571 sg.print_graph(label)
Tim Hall79d07d22020-04-27 18:20:16 +0100572
573 def print_graph_with_tensors(self):
574 for sg in self.subgraphs:
575 sg.print_graph_with_tensors()
576
577 def print_graph_with_tensor_quantization(self):
578 for sg in self.subgraphs:
579 sg.print_graph_with_tensor_quantization()
580
581 def print_passes(self):
582 for sg in self.subgraphs:
583 sg.print_passes()
584
585 def print_passes_with_tensors(self):
586 for sg in self.subgraphs:
587 sg.print_passes_with_tensors()
588
589 def print_cascaded_passes(self):
590 for sg in self.subgraphs:
591 sg.print_cascaded_passes()
592
593 def print_cascaded_passes_with_tensors(self):
594 for sg in self.subgraphs:
595 sg.print_cascaded_passes_with_tensors()
596
597 def print_cascaded_passes_with_tensor_sizes(self):
598 for sg in self.subgraphs:
599 sg.print_cascaded_passes_with_tensor_sizes()
600
601 def print_high_level_command_stream(self):
602 for sg in self.subgraphs:
603 sg.print_high_level_command_stream()