blob: 9e237f84b38b620bc3eb8acdf2b09d7fb883dc6d [file] [log] [blame]
erik.andersson@arm.comad45f792021-02-03 10:20:16 +01001# Copyright (C) 2020-2021 Arm Limited or its affiliates. All rights reserved.
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.
Tim Hall79d07d22020-04-27 18:20:16 +010016# Description:
17# Main entry point for the Vela compiler.
18#
19# Provides command line interface, options parsing, and network loading. Before calling the compiler driver.
Diego Russoe8a10452020-04-21 17:39:10 +010020import argparse
Tim Hall1bd531d2020-11-01 20:59:36 +000021import os
Diego Russoea6111a2020-04-14 18:41:58 +010022import sys
Tim Hall79d07d22020-04-27 18:20:16 +010023import time
Tim Hall79d07d22020-04-27 18:20:16 +010024
erik.andersson@arm.comad45f792021-02-03 10:20:16 +010025import flatbuffers
26
Tim Hall79d07d22020-04-27 18:20:16 +010027from . import architecture_features
Diego Russoe8a10452020-04-21 17:39:10 +010028from . import compiler_driver
29from . import model_reader
30from . import scheduler
Tim Hall79d07d22020-04-27 18:20:16 +010031from . import stats_writer
32from . import tflite_writer
Tim Hall79d07d22020-04-27 18:20:16 +010033from ._version import __version__
Louis Verhaard11831ce2020-11-18 18:53:24 +010034from .api import API_VERSION
Tim Halle6ccd872020-11-09 16:46:37 +000035from .debug_database import DebugDatabase
Louis Verhaard7db78962020-05-25 15:05:26 +020036from .errors import InputFileError
Henrik G Olssonea9b23c2021-03-23 17:34:49 +010037from .errors import VelaError
Jonas Ohlsson45e653d2021-07-26 16:13:12 +020038from .nn_graph import NetworkType
Diego Russoe8a10452020-04-21 17:39:10 +010039from .nn_graph import PassPlacement
40from .nn_graph import TensorAllocator
Diego Russoea6111a2020-04-14 18:41:58 +010041from .tensor import MemArea
Jacob Bohlin0628a8c2020-08-28 13:25:14 +020042from .tensor import Tensor
erik.andersson@arm.comad45f792021-02-03 10:20:16 +010043from .tflite.Model import Model
Michael McGeagh837dc1b2020-11-10 12:38:25 +000044from .tflite_mapping import builtin_operator_map
45from .tflite_mapping import builtin_type_name
Jonas Ohlsson45e653d2021-07-26 16:13:12 +020046from .tflite_model_semantic import TFLiteSemantic
47from .tflite_supported_operators import TFLiteSupportedOperators
48from .tosa_model_semantic import TosaSemantic
49from .tosa_supported_operators import TosaSupportedOperators
Louis Verhaard52078302020-11-18 13:35:06 +010050from ethosu.vela.architecture_features import ArchitectureFeatures
Tim Hall79d07d22020-04-27 18:20:16 +010051
52
Tim Halle6ccd872020-11-09 16:46:37 +000053def process(input_name, enable_debug_db, arch, model_reader_options, compiler_options, scheduler_options):
Tim Hall79d07d22020-04-27 18:20:16 +010054 if compiler_options.timing:
55 start = time.time()
56
Tim Halle6ccd872020-11-09 16:46:37 +000057 os.makedirs(compiler_options.output_dir, exist_ok=True)
58 output_basename = os.path.join(compiler_options.output_dir, os.path.splitext(os.path.basename(input_name))[0])
59 DebugDatabase.show_warnings = enable_debug_db
60
Patrik Gustavsson8f1f9aa2021-06-28 07:41:58 +020061 nng, network_type = model_reader.read_model(input_name, model_reader_options)
Tim Hall79d07d22020-04-27 18:20:16 +010062
63 if not nng:
Michael McGeagh7a6f8432020-12-02 15:29:22 +000064 raise InputFileError(input_name, "Input file could not be read")
Tim Hall79d07d22020-04-27 18:20:16 +010065
66 if compiler_options.verbose_operators:
67 nng.print_operators()
68
69 if compiler_options.timing:
70 stop = time.time()
71 print("Model reading took %f s" % (stop - start))
72 start = time.time()
73
Patrik Gustavsson8f1f9aa2021-06-28 07:41:58 +020074 compiler_driver.compiler_driver(nng, arch, compiler_options, scheduler_options, network_type)
Tim Hall79d07d22020-04-27 18:20:16 +010075
Tim Halle6ccd872020-11-09 16:46:37 +000076 summary_csv_file = "{0}_summary_{1}.csv".format(output_basename, arch.system_config)
Tim Hall79d07d22020-04-27 18:20:16 +010077 stats_writer.write_summary_metrics_csv(nng, summary_csv_file, arch)
78
Fredrik Svedbergf5c07c42021-04-23 14:36:42 +020079 stats_writer.print_performance_metrics(
80 nng,
81 show_cpu_operations=compiler_options.show_cpu_operations,
82 verbose_weights=compiler_options.verbose_weights,
83 arch=arch,
84 )
Tim Hall79d07d22020-04-27 18:20:16 +010085
Tim Halle6ccd872020-11-09 16:46:37 +000086 output_filename = output_basename + "_vela.tflite"
87 if input_name.endswith(".tflite"):
88 tflite_writer.write_tflite(nng, output_filename)
89
90 if enable_debug_db:
erik.andersson@arm.comad45f792021-02-03 10:20:16 +010091 file_offsets = calculate_operator_file_offsets(output_filename)
92 for idx, offset in enumerate(sorted(file_offsets)):
93 sg = find_subgraph_with_command_stream_order(nng, idx)
94 if sg is not None:
95 DebugDatabase.set_stream_offset(sg, offset)
Tim Halle6ccd872020-11-09 16:46:37 +000096 debug_filename = output_basename + "_debug.xml"
97 DebugDatabase.write(debug_filename, input_name, output_filename)
Tim Hall79d07d22020-04-27 18:20:16 +010098
99 if compiler_options.timing:
100 stop = time.time()
101 print("Compiler driver took %f s" % (stop - start))
102
103 return nng
104
105
erik.andersson@arm.comad45f792021-02-03 10:20:16 +0100106def find_subgraph_with_command_stream_order(nng, idx):
107 for sg in nng.subgraphs:
108 if sg.generated_stream_id == idx:
109 return sg
110 return None
111
112
113def calculate_operator_file_offsets(name: str):
114 # Read the vela optimized tflite file
115 with open(name, "rb") as f:
116 buf = bytearray(f.read())
117 # Calculate the file offsets for each custom operator
118 file_offsets = []
119 model = Model.GetRootAsModel(buf, 0)
120 for idx in range(model.SubgraphsLength()): # However only one subgraph is supported as of now
121 sg = model.Subgraphs(idx)
122 for idx in range(sg.OperatorsLength()):
123 operator = sg.Operators(idx)
124 if model.OperatorCodes(operator.OpcodeIndex()).CustomCode() is not None:
125 tensor_idx = operator.Inputs(0)
126 tensor = sg.Tensors(tensor_idx)
127 buffer = model.Buffers(tensor.Buffer())
128 offset = flatbuffers.number_types.UOffsetTFlags.py_type(buffer._tab.Offset(4))
129 file_offsets.append(buffer._tab.Vector(offset))
130 return file_offsets
131
132
Tim Hall79d07d22020-04-27 18:20:16 +0100133def print_subgraph_io_summary(nng):
134 """Print a summary of all the input and output tensor sizes for all subgraphs.
135 Also displays the total tensor size and the memory used area for sram.
136 """
137
138 print("Subgraph IO Summary")
139 print("-------------------")
140 print("NNG: {0}".format(nng.name))
141 max_sg_size = 0
142 for sg in reversed(nng.subgraphs):
143 print(" Subgraph: {0} = {1}".format(sg.name, sg.placement))
144 sg_size = 0
145
146 if sg.placement == PassPlacement.Npu:
147 for tens in sg.input_tensors + [sg.scratch_tensor] + sg.output_tensors:
148 if tens in sg.input_tensors:
149 tens_dir = "In"
150 elif tens in sg.output_tensors:
151 tens_dir = "Out"
152 else:
153 tens_dir = "In/Out"
154
155 size = tens.elements() * tens.element_size() / 1024.0
156 sg_size = sg_size + size
157 print(" Tensor [{0}]: {1} = {2} KiB".format(tens_dir, tens.name, size))
158
159 print(" Total Size = {0} KiB".format(sg_size))
160 print(" SRAM Memory Used = {0} KiB".format(sg.memory_used.get(MemArea.Sram, 0) / 1024.0))
161 max_sg_size = max(sg_size, max_sg_size)
162
163 print(" Maximum Subgraph Size = {0} KiB".format(max_sg_size))
164
165
Michael McGeagh837dc1b2020-11-10 12:38:25 +0000166def generate_supported_ops():
167 lines = [
168 "# Supported Ops",
169 "",
170 "This file was automatically generated by Vela using the `--supported-ops-report` parameter. ",
171 f"Vela version: `{__version__}`",
172 "",
Michael McGeagh54a61112020-11-24 14:58:51 +0000173 "This file complies with",
174 "[**Gitiles Markdown syntax**](https://github.com/google/gitiles/blob/master/Documentation/markdown.md)",
Michael McGeagh837dc1b2020-11-10 12:38:25 +0000175 "",
Jonas Ohlsson45e653d2021-07-26 16:13:12 +0200176 "Summary table of constraints for:",
Michael McGeagh837dc1b2020-11-10 12:38:25 +0000177 ]
Jonas Ohlsson45e653d2021-07-26 16:13:12 +0200178
179 for network_type in NetworkType:
180 lines += [
181 f"- [{network_type.name}](#{network_type.name.lower()}-summary-table)",
182 ]
183
184 for network_type in NetworkType:
Michael McGeagh837dc1b2020-11-10 12:38:25 +0000185 lines += [
186 "",
Jonas Ohlsson45e653d2021-07-26 16:13:12 +0200187 f"## {network_type.name} Summary Table",
Michael McGeagh837dc1b2020-11-10 12:38:25 +0000188 "",
189 ]
Jonas Ohlsson45e653d2021-07-26 16:13:12 +0200190 if network_type == NetworkType.TFLite:
191 lines += [
192 "The table below contains TFLite operators that can be placed on the Ethos-U NPU. ",
193 "If the constraints are not met, then that operator will be scheduled on the CPU instead. ",
194 "For any other TFLite operator not listed, will be left untouched and scheduled on the CPU. ",
195 "Please check the supported operator list for your chosen runtime for further information.",
196 "",
197 "| Operator | TFLite Constraints |",
198 "| --- | --- |",
199 ]
200 semantic_checker = TFLiteSemantic()
201 supported = TFLiteSupportedOperators()
202 elif network_type == NetworkType.TOSA:
203 lines += [
204 "The table below contains TOSA operators that can be placed on the Ethos-U NPU. ",
205 "Note: There is limited support for compiling a TOSA neural network (EXPERIMENTAL). ",
206 "The related constraints have not yet been populated in the list.",
207 "",
208 "| Operator | TOSA Constraints |",
209 "| --- | --- |",
210 ]
211 semantic_checker = TosaSemantic()
212 supported = TosaSupportedOperators()
213 else:
214 raise ValueError
215
216 op_constraint_links = []
217 op_list = sorted(((op, builtin_type_name(op)) for op in builtin_operator_map), key=lambda x: x[1])
218 for op, name in op_list:
219 internal_op = builtin_operator_map[op][0]
220 if internal_op in TFLiteSupportedOperators.supported_operators:
221 links = f"[Generic](#{network_type.name.lower()}-generic-constraints)"
222 if (
223 internal_op in supported.specific_constraints
224 or internal_op in semantic_checker.specific_constraints
225 ):
226 links += f", [Specific](#{network_type.name.lower()}-{name.lower()}-constraints)"
227 op_constraint_links.append((internal_op, name))
228 lines.append(f"| {name} | {links} |")
229 lines += [
230 "",
231 f"### {network_type.name} Generic Constraints",
232 "",
233 "This is a list of constraints that all NPU operators must satisfy in order to be scheduled on the NPU.",
234 "",
235 ]
236 for constraint in semantic_checker.generic_constraints:
Michael McGeagh837dc1b2020-11-10 12:38:25 +0000237 # Markdown needs two spaces at the end of a line to render it as a separate line
238 reason = constraint.__doc__.replace("\n", " \n")
239 lines.append(f"- {reason}")
Jonas Ohlsson45e653d2021-07-26 16:13:12 +0200240 for constraint in supported.generic_constraints:
241 # Markdown needs two spaces at the end of a line to render it as a separate line
242 reason = constraint.__doc__.replace("\n", " \n")
243 lines.append(f"- {reason}")
244 for op, name in op_constraint_links:
245 lines += [
246 "",
247 f"### {network_type.name} {name} Constraints",
248 "",
249 f"This is a list of constraints that the {name} operator must satisfy in order to be scheduled on the"
250 " NPU.",
251 "",
252 ]
253 for constraint in semantic_checker.specific_constraints[op]:
254 # Markdown needs two spaces at the end of a line to render it as a separate line
255 reason = constraint.__doc__.replace("\n", " \n")
256 lines.append(f"- {reason}")
257 for constraint in supported.specific_constraints[op]:
258 # Markdown needs two spaces at the end of a line to render it as a separate line
259 reason = constraint.__doc__.replace("\n", " \n")
260 lines.append(f"- {reason}")
Michael McGeagh837dc1b2020-11-10 12:38:25 +0000261
262 # Note. this will generate the file in the CWD
263 filepath = os.path.join(os.getcwd(), "SUPPORTED_OPS.md")
264 with open(filepath, "wt") as md:
265 md.writelines(line + "\n" for line in lines)
266 print(f"Report file: {filepath}")
267
268
Tim Hall79d07d22020-04-27 18:20:16 +0100269def main(args=None):
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100270 try:
271 if args is None:
272 args = sys.argv[1:]
Tim Hall79d07d22020-04-27 18:20:16 +0100273
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100274 parser = argparse.ArgumentParser(prog="vela", description="Neural network model compiler for Arm Ethos-U NPUs")
275 parser.add_argument("--version", action="version", version=__version__)
276 parser.add_argument(
277 "--api-version", action="version", version=API_VERSION, help="Displays the version of the external API."
278 )
279 parser.add_argument(
280 "--supported-ops-report",
281 action="store_true",
282 help="Generate the SUPPORTED_OPS.md file in the current working directory and exit",
Tim Hallb9b515c2020-11-01 21:27:19 +0000283 )
Jacob Bohlin0628a8c2020-08-28 13:25:14 +0200284
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100285 # set network nargs to be optional to allow the support-ops-report CLI option to be used standalone
286 parser.add_argument(
287 "network",
288 metavar="NETWORK",
289 type=str,
290 default=None,
291 nargs="?",
292 help="Filename of the input TensorFlow Lite for Microcontrollers network",
293 )
294 parser.add_argument(
295 "--output-dir", type=str, default="output", help="Output directory to write files to (default: %(default)s)"
296 )
297 parser.add_argument(
298 "--enable-debug-db",
299 action="store_true",
300 default=None,
301 help="Enables the calculation and writing of a network debug database to output directory",
302 )
303 parser.add_argument(
304 "--config",
305 type=str,
306 action="append",
307 help="Vela configuration file(s) in Python ConfigParser .ini file format",
308 )
309 parser.add_argument("--verbose-all", action="store_true", help="Enable all verbose options")
310 parser.add_argument(
311 "--verbose-config", action="store_true", help="Verbose system configuration and memory mode"
312 )
313 parser.add_argument("--verbose-graph", action="store_true", help="Verbose graph rewriter")
314 parser.add_argument("--verbose-quantization", action="store_true", help="Verbose quantization")
315 parser.add_argument("--verbose-packing", action="store_true", help="Verbose pass packing")
316 parser.add_argument("--verbose-tensor-purpose", action="store_true", help="Verbose tensor purpose")
317 parser.add_argument("--verbose-tensor-format", action="store_true", help="Verbose tensor format")
318 parser.add_argument("--verbose-schedule", action="store_true", help="Verbose schedule")
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100319 parser.add_argument("--verbose-allocation", action="store_true", help="Verbose tensor allocation")
320 parser.add_argument(
321 "--verbose-high-level-command-stream", action="store_true", help="Verbose high level command stream"
322 )
323 parser.add_argument(
324 "--verbose-register-command-stream", action="store_true", help="Verbose register command stream"
325 )
326 parser.add_argument("--verbose-operators", action="store_true", help="Verbose operator list")
Fredrik Svedbergf5c07c42021-04-23 14:36:42 +0200327 parser.add_argument("--verbose-weights", action="store_true", help="Verbose weights information")
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100328 parser.add_argument(
329 "--show-cpu-operations", action="store_true", help="Show the operations that fall back to the CPU"
330 )
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100331 parser.add_argument("--timing", action="store_true", help="Time the compiler doing operations")
332 parser.add_argument(
333 "--accelerator-config",
334 type=str,
335 default="ethos-u55-256",
336 choices=list(architecture_features.Accelerator.member_list()),
337 help="Accelerator configuration to use (default: %(default)s)",
338 )
339 parser.add_argument(
340 "--system-config",
341 type=str,
342 default=architecture_features.ArchitectureFeatures.DEFAULT_CONFIG,
343 help="System configuration to select from the Vela configuration file (default: %(default)s)",
344 )
345 parser.add_argument(
346 "--memory-mode",
347 type=str,
348 default=architecture_features.ArchitectureFeatures.DEFAULT_CONFIG,
349 help="Memory mode to select from the Vela configuration file (default: %(default)s)",
350 )
351 parser.add_argument(
352 "--tensor-allocator",
353 default=TensorAllocator.HillClimb,
354 type=lambda s: TensorAllocator[s],
355 choices=list(TensorAllocator),
356 help="Tensor Allocator algorithm (default: %(default)s)",
357 )
358 parser.add_argument(
359 "--show-subgraph-io-summary",
360 action="store_true",
361 help="Shows a summary of all the subgraphs and their inputs and outputs",
362 )
363 parser.add_argument(
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100364 "--max-block-dependency",
365 type=int,
366 default=architecture_features.ArchitectureFeatures.MAX_BLOCKDEP,
367 choices=range(0, architecture_features.ArchitectureFeatures.MAX_BLOCKDEP + 1),
368 help=(
369 "Set the maximum value that can be used for the block dependency between npu kernel operations"
370 " (default: %(default)s)"
371 ),
372 )
373 parser.add_argument(
Tim Halld8339a72021-05-27 18:49:40 +0100374 "--optimise",
375 type=lambda s: scheduler.OptimizationStrategy[s],
376 default=scheduler.OptimizationStrategy.Performance,
377 choices=list(scheduler.OptimizationStrategy),
378 help=(
379 "Set the optimisation strategy. The Size strategy results in minimal SRAM usage (does not use"
380 " arena-cache-size). The Performance strategy results in maximal performance (uses the arena-cache-size"
381 " if specified) (default: %(default)s)"
382 ),
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100383 )
384 parser.add_argument(
Tim Halld8339a72021-05-27 18:49:40 +0100385 "--arena-cache-size",
386 type=int,
387 help=(
388 "Set the size of the arena cache memory area, in bytes. If specified, this option overrides the memory"
389 " mode attribute with the same name in a Vela configuration file"
390 ),
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100391 )
392 parser.add_argument(
393 "--cpu-tensor-alignment",
394 type=int,
395 default=Tensor.AllocationQuantum,
396 help=(
397 "Controls the allocation byte alignment of cpu tensors including Ethos-U Custom"
398 " operator inputs and outputs (default: %(default)s)"
399 ),
400 )
Dwight Lidmanb9c95422021-08-18 19:24:14 +0200401 parser.add_argument(
402 "--recursion-limit",
403 type=int,
404 default=1000,
405 help="Set the recursion depth limit, may result in RecursionError if too low (default: %(default)s)",
406 )
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100407 args = parser.parse_args(args=args)
Louis Verhaard52078302020-11-18 13:35:06 +0100408
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100409 # Generate the supported ops report and exit
410 if args.supported_ops_report:
411 generate_supported_ops()
412 return 0
Louis Verhaard52078302020-11-18 13:35:06 +0100413
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100414 if args.network is None:
415 parser.error("the following argument is required: NETWORK")
Michael McGeagh2fa40ae2020-12-02 10:55:04 +0000416
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100417 # check all config files exist because they will be read as a group
418 if args.config is not None:
419 for filename in args.config:
420 if not os.access(filename, os.R_OK):
421 raise InputFileError(filename, "File not found or is not readable")
Tim Hall79d07d22020-04-27 18:20:16 +0100422
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100423 if args.cpu_tensor_alignment < 16 or args.cpu_tensor_alignment & (args.cpu_tensor_alignment - 1) != 0:
424 parser.error(
425 "Invalid argument to --cpu-tensor-alignment = {} (must be greater than or equal to 16 and a power of 2)"
426 "".format(args.cpu_tensor_alignment)
427 )
Tim Hall79d07d22020-04-27 18:20:16 +0100428
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100429 if args.system_config == ArchitectureFeatures.DEFAULT_CONFIG:
430 print(f"Warning: Using {ArchitectureFeatures.DEFAULT_CONFIG} values for system configuration")
Tim Hall79d07d22020-04-27 18:20:16 +0100431
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100432 if args.memory_mode == ArchitectureFeatures.DEFAULT_CONFIG:
433 print(f"Warning: Using {ArchitectureFeatures.DEFAULT_CONFIG} values for memory mode")
Tim Hall79d07d22020-04-27 18:20:16 +0100434
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100435 if args.verbose_all:
436 for v in vars(args):
437 if v.startswith("verbose") and v != "verbose_all":
438 setattr(args, v, True)
439
Dwight Lidmanb9c95422021-08-18 19:24:14 +0200440 sys.setrecursionlimit(args.recursion_limit)
441
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100442 arch = architecture_features.ArchitectureFeatures(
443 vela_config_files=args.config,
444 system_config=args.system_config,
445 memory_mode=args.memory_mode,
446 accelerator_config=args.accelerator_config,
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100447 max_blockdep=args.max_block_dependency,
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100448 verbose_config=args.verbose_config,
Tim Halld8339a72021-05-27 18:49:40 +0100449 arena_cache_size=args.arena_cache_size,
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100450 )
451
452 compiler_options = compiler_driver.CompilerOptions(
453 verbose_graph=args.verbose_graph,
454 verbose_quantization=args.verbose_quantization,
455 verbose_packing=args.verbose_packing,
456 verbose_tensor_purpose=args.verbose_tensor_purpose,
457 verbose_tensor_format=args.verbose_tensor_format,
458 verbose_allocation=args.verbose_allocation,
459 verbose_high_level_command_stream=args.verbose_high_level_command_stream,
460 verbose_register_command_stream=args.verbose_register_command_stream,
461 verbose_operators=args.verbose_operators,
Fredrik Svedbergf5c07c42021-04-23 14:36:42 +0200462 verbose_weights=args.verbose_weights,
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100463 show_cpu_operations=args.show_cpu_operations,
464 tensor_allocator=args.tensor_allocator,
465 timing=args.timing,
466 output_dir=args.output_dir,
467 cpu_tensor_alignment=args.cpu_tensor_alignment,
468 )
469
470 scheduler_options = scheduler.SchedulerOptions(
Tim Halld8339a72021-05-27 18:49:40 +0100471 optimization_strategy=args.optimise,
472 sram_target=arch.arena_cache_size,
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100473 verbose_schedule=args.verbose_schedule,
Henrik G Olssonea9b23c2021-03-23 17:34:49 +0100474 )
475
476 model_reader_options = model_reader.ModelReaderOptions()
477
478 nng = process(
479 args.network, args.enable_debug_db, arch, model_reader_options, compiler_options, scheduler_options
480 )
481
482 if args.show_subgraph_io_summary:
483 print_subgraph_io_summary(nng)
484
485 return 0
486 except VelaError as e:
487 print(e.data)
488 return 1