blob: e71e95b1239ec34bcd8d49bc906c762c79397553 [file] [log] [blame]
Tim Hall79d07d22020-04-27 18:20:16 +01001# Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
2#
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.
Tim Hall79d07d22020-04-27 18:20:16 +010016# Description:
17# NPU performance estimation functions to estimate performance of a Pass and CascadedPass. Uses a model that takes the
18# maximum of the 'cycles required for bandwidth' and 'cycles required for computing'.
19#
20# Called during scheduling to evaluate different proposals, as well as post-scheduling to provide a final performance
21# estimate.
Tim Hall79d07d22020-04-27 18:20:16 +010022import enum
Diego Russoea6111a2020-04-14 18:41:58 +010023
Tim Hall79d07d22020-04-27 18:20:16 +010024import numpy as np
Diego Russoea6111a2020-04-14 18:41:58 +010025
26from . import numeric_util
Diego Russoe8a10452020-04-21 17:39:10 +010027from .architecture_features import Block
Diqing Zhonge8887a32020-09-24 09:53:48 +020028from .architecture_features import SHRAMElements
29from .data_type import DataType
Diego Russoe8a10452020-04-21 17:39:10 +010030from .nn_graph import PassPlacement
31from .nn_graph import SchedulerRewrite
Diego Russoea6111a2020-04-14 18:41:58 +010032from .operation import NpuBlockType
Diqing Zhonge8887a32020-09-24 09:53:48 +020033from .operation import Op
Louis Verhaard93dc5532020-06-07 12:40:18 +020034from .register_command_stream_generator import get_op_kernel
Diego Russoe8a10452020-04-21 17:39:10 +010035from .tensor import MemArea
36from .tensor import shape_num_elements
37from .tensor import TensorBlockTraversal
38from .tensor import TensorPurpose
Tim Hall79d07d22020-04-27 18:20:16 +010039
40
41def rolling_buffer_dims_from_passes(arch, ps1, block_config_ps1, ps2, block_config_ps2):
Tim Hall79d07d22020-04-27 18:20:16 +010042 ofm_block = Block(block_config_ps2[-3], block_config_ps2[-4], block_config_ps2[-1])
Louis Verhaard93dc5532020-06-07 12:40:18 +020043 kernel = get_op_kernel(ps2)
Tim Hall79d07d22020-04-27 18:20:16 +010044
45 if ps2.npu_block_type in set((NpuBlockType.ConvolutionMxN, NpuBlockType.VectorProduct)):
Louis Verhaard93dc5532020-06-07 12:40:18 +020046 op = ps2.primary_op
Louis Verhaardaee5d752020-09-30 09:01:52 +020047 ifm_block_depth = arch.calc_ifm_block_depth(op.ifm.shape[-1], op.ifm.dtype.size_in_bits())
Tim Hall79d07d22020-04-27 18:20:16 +010048 else:
49 ifm_block_depth = block_config_ps2[-1]
50
Louis Verhaard93dc5532020-06-07 12:40:18 +020051 ifm_block = arch.get_ifm_block_size(ifm_block_depth, ofm_block, kernel, arch.ofm_block_max)
Tim Hall79d07d22020-04-27 18:20:16 +010052
53 # The performed height calculation is for worst case
54 height = numeric_util.round_up(ifm_block.height + block_config_ps1[0], block_config_ps1[0])
55 width = ifm_block.width
Louis Verhaard93dc5532020-06-07 12:40:18 +020056 return [height, width]
Tim Hall79d07d22020-04-27 18:20:16 +010057
58
59class PassCycles(enum.IntEnum):
60 Dpu = 0
61 ElementWise = 1
62 Cpu = 2
63 SramAccess = 3
64 TotalPerPass = 4
65 DramAccess = 5
66 OnChipFlashAccess = 6
67 OffChipFlashAccess = 7
68 Total = 8
69 Size = 9
70
71 def display_name(self):
72 return (
73 "DPU",
74 "Element wise",
75 "CPU",
76 "SRAM Access",
77 "Total per Pass",
78 "DRAM Access",
79 "On-chip Flash Access",
80 "Off-chip Flash Access",
81 "Total",
82 "Size",
83 )[self.value]
84
85 def identifier_name(self):
86 return (
87 "dpu",
88 "element_wise",
89 "cpu",
90 "sram_access",
91 "total_per_pass",
92 "dram_access",
93 "on_chip_flash_access",
94 "off_chip_flash_access",
95 "total",
96 "size",
97 )[self.value]
98
99 @staticmethod
100 def all():
101 return (
102 PassCycles.Dpu,
103 PassCycles.ElementWise,
104 PassCycles.Cpu,
105 PassCycles.SramAccess,
106 PassCycles.DramAccess,
107 PassCycles.OnChipFlashAccess,
108 PassCycles.OffChipFlashAccess,
109 PassCycles.Total,
110 )
111
112
113class MacCount(enum.IntEnum):
114 NeuralNetworkMacs = 0
115 HardwareMacs = 1
116 Size = 2
117
118 def display_name(self):
119 return ("Neural Network Macs", "Hardware Macs", "Size")[self.value]
120
121 def identifier_name(self):
122 return ("nn_macs", "hardware_macs", "size")[self.value]
123
124 @staticmethod
125 def all():
126 return (MacCount.NeuralNetworkMacs, MacCount.HardwareMacs)
127
128
129class BandwidthDirection(enum.IntEnum):
130 Read = 0
131 Write = 1
132 Size = 2
133
134 def display_name(self):
135 return self.name
136
137 def identifier_name(self):
138 return self.name.lower()
139
140 @staticmethod
141 def all():
142 return (BandwidthDirection.Read, BandwidthDirection.Write)
143
144
145def make_bandwidth_array():
146 return np.zeros((MemArea.Size, TensorPurpose.Size, BandwidthDirection.Size))
147
148
149def make_macs_array():
150 return np.zeros(MacCount.Size, np.int)
151
152
153def make_cycles_array():
154 return np.zeros(PassCycles.Size)
155
156
157def make_metrics_arrays():
158 return (make_bandwidth_array(), make_macs_array(), make_cycles_array())
159
160
161def get_n_blocks_and_area(
162 ifm_brick_size, ifm_height_width, orig_skirt, clamped_skirt, block_config, min_block_size, strides
163):
164
165 ifm_block_config = (block_config[0] * strides[1], block_config[1] * strides[2])
166
167 n_normal_blocks = []
168 remainder_size = []
169 for i in range(2):
170 non_skirt_dim = ifm_height_width[i] - orig_skirt[i] - orig_skirt[2 + i]
171 n_blocks = non_skirt_dim // ifm_block_config[i]
172 n_normal_blocks.append(n_blocks)
173 remainder_dim = numeric_util.round_up(
174 ((non_skirt_dim - n_blocks * ifm_block_config[i] - 1) // strides[i + 1]) + 1, min_block_size[i]
175 )
176 remainder_size.append(remainder_dim)
177
178 # this will actually calculate reads into the edge padding.
179
180 # there are four cases in total, handling the edges that will not fill a complete block.
181
182 # 0000000001
183 # 0000000001
184 # 0000000001
185 # 0000000001
186 # 0000000001
187 # 0000000001
188 # 2222222223
189 total_blocks = 0
190 total_area = 0
191
192 block_setup = (
193 (n_normal_blocks[0] * n_normal_blocks[1], block_config),
194 (1 * n_normal_blocks[1], (remainder_size[0], block_config[1])),
195 (n_normal_blocks[0] * 1, (block_config[0], remainder_size[1])),
196 (1 * 1, remainder_size),
197 )
198
199 for n_blocks, block_size in block_setup:
200 if block_size[0] == 0 or block_size[1] == 0:
201 continue
202 read_dims = [0, 0]
203 for i in range(2):
204 read_dims[i] = (
205 numeric_util.round_up(clamped_skirt[i], ifm_brick_size[i + 1])
206 + block_size[i] * strides[i + 1]
207 + numeric_util.round_up(clamped_skirt[2 + i], ifm_brick_size[i + 1])
208 )
209 assert n_blocks >= 0
210 total_blocks += n_blocks
211 total_area += n_blocks * read_dims[0] * read_dims[1]
212 assert total_blocks >= 1
213 return total_blocks, total_area, block_setup
214
215
Diqing Zhonge8887a32020-09-24 09:53:48 +0200216def get_output_cycle_estimate(arch, ps):
217 primary_op = ps.primary_op
218 assert primary_op
219 npu_block_type = primary_op.type.npu_block_type
220 faf = primary_op.activation
221
222 if npu_block_type == NpuBlockType.ElementWise and ps.ifm_tensor.dtype == DataType.int32:
223 if ps.ifm2_tensor is None:
224 # Unary op
225 output_perf_index = 0
226 else:
227 # Binary op
228 output_perf_index = 1
229 elif ps.primary_op.type == Op.Mul and ps.ofm_tensor.dtype == DataType.int32:
230 output_perf_index = 2
231 elif ps.primary_op.type == Op.Mul or (
232 npu_block_type
233 in (
234 NpuBlockType.ConvolutionMxN,
235 NpuBlockType.ConvolutionDepthWise,
236 NpuBlockType.Pooling,
237 NpuBlockType.ReduceSum,
238 NpuBlockType.VectorProduct,
239 )
240 and ps.shared_buffer.use_accumulator_element == SHRAMElements.Acc40
241 ):
242 output_perf_index = 3
243 elif ps.primary_op.type in (Op.Add, Op.Sub):
244 input_scale = ps.ifm_tensor.quantization.scale_f32
245 input2_scale = ps.ifm2_tensor.quantization.scale_f32
246 output_scale = ps.ofm_tensor.quantization.scale_f32
247
248 if "resizebilinear" in primary_op.attrs:
249 output_scale = input2_scale
250
251 if None in (input_scale, input2_scale, output_scale) or input_scale == input2_scale:
252 # Simple Add/Sub
253 output_perf_index = 4
254 else:
255 # Advanced Add/Sub
256 output_perf_index = 5
257 elif ps.primary_op.type.is_maxpool_op():
258 output_perf_index = 6
259 else:
260 output_perf_index = 7
261
262 if faf in (Op.Sigmoid, Op.Tanh, Op.LUT):
263 activation_perf_index = 0
264 elif faf in (Op.Relu, Op.Relu6, Op.ReluN1To1):
265 activation_perf_index = 1
266 else:
267 activation_perf_index = 2
268
269 num_elems = ps.outputs[0].elements()
270 cycle_per_elem = max(
271 arch.output_cycles_per_elem[output_perf_index], arch.activation_cycles_per_elem[activation_perf_index]
272 )
273 return num_elems * cycle_per_elem
274
275
Tim Hall79d07d22020-04-27 18:20:16 +0100276def performance_metrics_for_pass(arch, ps, block_config=None, rewrite_list=[], force_outputs_to_fast_storage=False):
277 if block_config is None:
278 block_config = ps.block_config
279 bws = make_bandwidth_array()
280 macs = make_macs_array()
281 cycles = make_cycles_array()
282 blocks = 0
283 ifm_read_multiple = 1
284 weight_read_multiple = 0
285
286 if ps.placement in set((PassPlacement.MemoryOnly, PassPlacement.StartupInit)):
287 return bws, macs, cycles, blocks, ifm_read_multiple, weight_read_multiple # nothing real happening in this pass
288
289 min_block_size = arch.min_block_sizes[ps.npu_block_type]
290
291 skirt = (0, 0, 0, 0)
292 explicit_padding = (0, 0, 0, 0)
293 primary_op = ps.primary_op
294 replacement_read_bws = {}
Charles Xub02c8d92020-06-25 16:05:25 +0200295 if ps.placement == PassPlacement.Cpu:
296 cycles[PassCycles.Cpu] = arch.cpu_cycle_estimate(ps.ops[0])
297 elif primary_op:
Tim Hall79d07d22020-04-27 18:20:16 +0100298 skirt = primary_op.attrs.get("skirt", skirt)
299 explicit_padding = primary_op.attrs.get("explicit_padding", explicit_padding)
Louis Verhaardaee5d752020-09-30 09:01:52 +0200300 assert primary_op.type.npu_block_type == ps.npu_block_type
301 npu_block_type = primary_op.type.npu_block_type
Tim Hall79d07d22020-04-27 18:20:16 +0100302
303 ifm_tensor, _, weight_tensor, ofm_tensor = ps.get_primary_op_ifm_ifm2_weights_ofm()
304
Tim Hallc30f4952020-06-15 20:47:35 +0100305 if npu_block_type in set(
306 (NpuBlockType.ConvolutionMxN, NpuBlockType.ConvolutionDepthWise, NpuBlockType.Pooling)
307 ):
Charles Xu3e9c4342020-04-22 08:31:43 +0200308 # extent the ifm to full dimension
309 ifm_tensor_brick_size = tuple(numeric_util.full_shape(4, list(ifm_tensor.brick_size), 1))
310 ifm_tensor_shape = numeric_util.full_shape(4, ifm_tensor.shape, 1)
311 ifm_tensor_bandwidth_shape = numeric_util.full_shape(4, ifm_tensor.bandwidth_shape, 1)
Tim Hall79d07d22020-04-27 18:20:16 +0100312
313 batch_size = ifm_tensor.shape[0]
Charles Xu3e9c4342020-04-22 08:31:43 +0200314 ifm_depth = ifm_tensor_bandwidth_shape[3]
Tim Hall79d07d22020-04-27 18:20:16 +0100315
316 # add in padding
317 ifm_tensor_shape[1] += explicit_padding[0] + explicit_padding[2] # height += top and bottom
318 ifm_tensor_shape[2] += explicit_padding[1] + explicit_padding[3] # width += left and right
319
320 strides = primary_op.attrs["strides"]
321 if npu_block_type != NpuBlockType.Pooling:
322 weight_tensor_shape = weight_tensor.shape
323 weight_tensor_bandwidth_shape = weight_tensor.bandwidth_shape
324 weight_tensor_element_size = weight_tensor.element_size()
325 weight_tensor_bandwidth_compression_scale = weight_tensor.bandwidth_compression_scale
326 nn_ops = (
327 int(ofm_tensor.shape[0])
328 * int(ofm_tensor.shape[1])
329 * int(ofm_tensor.shape[2])
330 * int(weight_tensor_shape[0])
331 * int(weight_tensor_shape[1])
332 * int(weight_tensor_shape[2])
333 * int(weight_tensor_shape[3])
Tim Hall79d07d22020-04-27 18:20:16 +0100334 )
335 else:
336 weight_tensor_shape = [
337 primary_op.attrs["ksize"][1],
338 primary_op.attrs["ksize"][2],
339 1,
340 ifm_tensor_shape[3],
341 ]
342 weight_tensor_bandwidth_shape = weight_tensor_shape
343 weight_tensor_element_size = 0
344 weight_tensor_bandwidth_compression_scale = 0.0
345 nn_ops = 0 # pooling doesn't count as NN ops
346
347 kernel_dims = weight_tensor_shape[:2]
348
349 sub_kernel_limits = arch.sub_kernel_limits[npu_block_type]
350 # count the sub kernels; the IFM block needs to be refetched for each of them
351 n_sub_kernels_y = numeric_util.round_up_divide(kernel_dims[0], sub_kernel_limits[0])
352 n_sub_kernels_x = numeric_util.round_up_divide(kernel_dims[1], sub_kernel_limits[1])
353 n_sub_kernels = n_sub_kernels_y * n_sub_kernels_x
354
355 clamped_skirt = list(skirt)
356 clamped_skirt[2] = min(clamped_skirt[2], sub_kernel_limits[0] - 1 - clamped_skirt[0])
357 clamped_skirt[3] = min(clamped_skirt[3], sub_kernel_limits[1] - 1 - clamped_skirt[1])
358 n_blocks, area, block_setup = get_n_blocks_and_area(
Charles Xu3e9c4342020-04-22 08:31:43 +0200359 ifm_tensor_brick_size,
Tim Hall79d07d22020-04-27 18:20:16 +0100360 ifm_tensor_shape[1:3],
361 skirt,
362 clamped_skirt,
363 block_config,
364 min_block_size,
365 strides,
366 )
367
368 blocks = n_blocks * numeric_util.round_up_divide(weight_tensor_shape[3], block_config[3])
369
370 n_weight_stages = numeric_util.round_up_divide(weight_tensor_bandwidth_shape[3], block_config[3])
371 if npu_block_type == NpuBlockType.ConvolutionDepthWise or npu_block_type == NpuBlockType.Pooling:
372 n_weight_stages = 1 # force to no reread
373
374 ifm_tensor_bw = (
375 n_sub_kernels
376 * batch_size
377 * area
378 * ifm_depth
379 * n_weight_stages
380 * ifm_tensor.element_size()
381 * ifm_tensor.bandwidth_compression_scale
382 )
383 replacement_read_bws[ifm_tensor] = ifm_tensor_bw
384 ifm_read_multiple = n_weight_stages
385
386 replacement_read_bws[weight_tensor] = (
387 batch_size
388 * shape_num_elements(weight_tensor_bandwidth_shape)
389 * weight_tensor_element_size
390 * weight_tensor_bandwidth_compression_scale
391 * n_blocks
392 ) # read once per block and batch
393 weight_read_multiple = n_blocks
394
395 n_kernel_xy = kernel_dims[0] * kernel_dims[1]
396 n_input_channels_at_a_time = block_config[2]
397
398 if npu_block_type == NpuBlockType.Pooling or weight_tensor.block_traversal in set(
399 (TensorBlockTraversal.PartKernelFirst, TensorBlockTraversal.DepthWise)
400 ):
401 n_input_channels_at_a_time = numeric_util.round_up_divide(n_input_channels_at_a_time, 4)
402 n_kernel_xy = max(
403 n_kernel_xy, 4
404 ) # need at least 4, as this is the minimum duty cycle for secondary accumulator writes
405 if weight_tensor is not None:
Diego Russoea6111a2020-04-14 18:41:58 +0100406 n_kernel_xy = numeric_util.round_up(n_kernel_xy, 4) # weights need to be read in blocks of 4
Tim Hall79d07d22020-04-27 18:20:16 +0100407
408 num_mac_ops = 0
409 for n_blocks_for_size, block_size in block_setup:
410 num_mac_ops += (
411 batch_size
412 * n_blocks_for_size
413 * block_size[0]
414 * block_size[1]
415 * numeric_util.round_up(weight_tensor_shape[2], n_input_channels_at_a_time)
416 * numeric_util.round_up(weight_tensor_shape[3], block_config[3])
417 * n_kernel_xy
418 )
419
420 if npu_block_type == NpuBlockType.Pooling:
421 # TODO: improve pooling estimation
422 cycles[PassCycles.Dpu] = num_mac_ops / arch.num_macs_per_cycle / 2
423 else:
424 cycles[PassCycles.Dpu] = num_mac_ops / arch.num_macs_per_cycle
425 macs[MacCount.NeuralNetworkMacs] += nn_ops
426 macs[MacCount.HardwareMacs] += num_mac_ops
427
428 elif npu_block_type == NpuBlockType.VectorProduct:
429 nn_macs = (
430 ifm_tensor.shape[0]
431 * numeric_util.round_up(weight_tensor.shape[-2], block_config[2])
432 * numeric_util.round_up(weight_tensor.shape[-1], block_config[3])
433 )
434 num_mac_ops = nn_macs
435
436 cycles[PassCycles.Dpu] = num_mac_ops / arch.num_macs_per_cycle
437 macs[MacCount.NeuralNetworkMacs] += nn_macs
438 macs[MacCount.HardwareMacs] += num_mac_ops
439
440 blocks = 1 * numeric_util.round_up_divide(weight_tensor.shape[-1], block_config[3])
441
442 non_zero_fraction = 1.0
443 if ifm_tensor.values is not None:
444 nz_vector = np.amax(ifm_tensor.values != 0, axis=0) # max across batch axis
445 non_zero_fraction = np.average(nz_vector)
446
447 replacement_read_bws[ifm_tensor] = ifm_tensor.bandwidth()
448 replacement_read_bws[weight_tensor] = weight_tensor.bandwidth() * non_zero_fraction
449 ifm_read_multiple = 1
450 weight_read_multiple = non_zero_fraction
Diqing Zhonge8887a32020-09-24 09:53:48 +0200451 elif npu_block_type == NpuBlockType.ElementWise:
Tim Hall79d07d22020-04-27 18:20:16 +0100452 # Work out how many elements we have and calculate performance.
Diqing Zhonge8887a32020-09-24 09:53:48 +0200453 cycles[PassCycles.ElementWise] = get_output_cycle_estimate(arch, ps)
Tim Hall79d07d22020-04-27 18:20:16 +0100454
Tim Hall79d07d22020-04-27 18:20:16 +0100455 # apply the desired rewrites
456 for rewrite_op, tens, _, _, _, ps_to_rewrite in rewrite_list:
457 if ps != ps_to_rewrite:
458 continue
459 if rewrite_op == SchedulerRewrite.Nop:
460 pass # these are fine, no bandwidth changes
461 elif rewrite_op in (SchedulerRewrite.ChangeTensorSubPurpose,):
462 bws[arch.fast_storage_mem_area][tens.purpose][BandwidthDirection.Read] += replacement_read_bws[tens]
463 replacement_read_bws[tens] = 0
464
465 for tens in ps.outputs:
466 if force_outputs_to_fast_storage:
467 bws[arch.fast_storage_mem_area][tens.purpose][BandwidthDirection.Write] += tens.bandwidth()
468 else:
469 bws[tens.mem_area][tens.purpose][BandwidthDirection.Write] += tens.bandwidth()
470
471 for tens in ps.intermediates:
472 bws[tens.mem_area][tens.purpose][BandwidthDirection.Write] += tens.bandwidth()
473
474 if tens in replacement_read_bws:
475 bw = replacement_read_bws[tens]
476 else:
477 bw = tens.bandwidth()
478
479 bws[tens.mem_area][tens.purpose][BandwidthDirection.Read] += bw
480
481 for tens in ps.inputs:
482 if tens in replacement_read_bws:
483 bw = replacement_read_bws[tens]
484 else:
485 bw = tens.bandwidth()
486
487 bws[tens.mem_area][tens.purpose][BandwidthDirection.Read] += bw
488
489 cycles[PassCycles.SramAccess] = np.sum(bws[MemArea.Sram]) / arch.memory_bandwidths_per_cycle[MemArea.Sram]
490 cycles[PassCycles.TotalPerPass] = np.max(cycles[: PassCycles.TotalPerPass])
491
492 # quick build access counts for only current pass, even though these aren't the final numbers
493 update_summary_cycles(arch, bws, macs, cycles)
494
495 return bws, macs, cycles, blocks, ifm_read_multiple, weight_read_multiple
496
497
498def update_summary_cycles(arch, bws, macs, cycles):
499 cycles[PassCycles.DramAccess] = np.sum(bws[MemArea.Dram]) / arch.memory_bandwidths_per_cycle[MemArea.Dram]
500 cycles[PassCycles.OnChipFlashAccess] = (
501 np.sum(bws[MemArea.OnChipFlash]) / arch.memory_bandwidths_per_cycle[MemArea.OnChipFlash]
502 )
503 cycles[PassCycles.OffChipFlashAccess] = (
504 np.sum(bws[MemArea.OffChipFlash]) / arch.memory_bandwidths_per_cycle[MemArea.OffChipFlash]
505 )
506
507 cycles[PassCycles.Total] = np.max(cycles[: PassCycles.Total])
508 return cycles
509
510
511def collate_stats_for_cascaded_pass(arch, bws, macs, cycles):
512 return bws, macs, cycles
513
514
515def performance_for_cascaded_pass(arch, cps):
516 total_bws = make_bandwidth_array()
517 total_macs = make_macs_array()
518 total_cycles = make_cycles_array()
519
520 for ps in cps.passes:
521 bws, macs, cycles, blocks, _, _ = performance_metrics_for_pass(arch, ps)
522 ps.bandwidths = bws
523 ps.macs = macs
524 ps.cycles = cycles
525 ps.n_blocks = blocks
526 total_bws += bws
527 total_macs += macs
528 total_cycles += cycles
529
530 bws, macs, cycles = collate_stats_for_cascaded_pass(arch, total_bws, total_macs, total_cycles)
531 cps.bandwidths = bws
532 cps.macs = macs
533 cps.cycles = cycles
534 return bws, macs, cycles
535
536
537def calc_performance_for_network(nng, arch):
538 total_bws = make_bandwidth_array()
539 total_macs = np.zeros(MacCount.Size)
540 total_cycles = np.zeros(PassCycles.Size)
541
542 for sg in nng.subgraphs:
543 for cps in sg.cascaded_passes:
544 bws, macs, cycles = performance_for_cascaded_pass(arch, cps)
545 total_bws += bws
546 total_macs += macs
547 total_cycles += cycles
Tim Hall79d07d22020-04-27 18:20:16 +0100548
549 nng.bandwidths = total_bws
550 nng.macs = total_macs
551 nng.cycles = total_cycles