diff options
Diffstat (limited to 'ethosu/vela')
-rw-r--r-- | ethosu/vela/driver_actions.py | 7 | ||||
-rw-r--r-- | ethosu/vela/npu_serialisation.py | 1 | ||||
-rw-r--r-- | ethosu/vela/register_command_stream_generator.py | 8 |
3 files changed, 15 insertions, 1 deletions
diff --git a/ethosu/vela/driver_actions.py b/ethosu/vela/driver_actions.py index 5a85df06..317b2a69 100644 --- a/ethosu/vela/driver_actions.py +++ b/ethosu/vela/driver_actions.py @@ -24,6 +24,7 @@ from .api import NpuAccelerator from .architecture_features import Accelerator from .architecture_features import ArchitectureFeatures from .architecture_features import create_default_arch +from .errors import VelaError from .ethos_u55_regs.ethos_u55_regs import ARCH_VER from .ethos_u55_regs.ethos_u55_regs import config_r from .ethos_u55_regs.ethos_u55_regs import id_r @@ -120,6 +121,12 @@ def create_driver_payload(register_command_stream: List[int], arch: Architecture da_list: List[int] = [] emit_fourcc(da_list, "COP1") emit_config(da_list, 0, 1, arch) + if len(register_command_stream) >= 1 << 24: + raise VelaError( + "The command stream exceeds the driver size limit of 64 MiB. " + f"The current stream size is {4*len(register_command_stream)/2**20:.2F} MiB" + ) + emit_cmd_stream_header(da_list, len(register_command_stream)) # Append command stream words diff --git a/ethosu/vela/npu_serialisation.py b/ethosu/vela/npu_serialisation.py index 66230537..27c46ea0 100644 --- a/ethosu/vela/npu_serialisation.py +++ b/ethosu/vela/npu_serialisation.py @@ -119,7 +119,6 @@ def serialise_npu_subgraph_into_tensors(nng, sg, arch, scratch_tens, scratch_fas ps.ifm2_tensor.mem_type not in (MemType.Scratch, MemType.Scratch_fast) ): copy_ifm_values_to_memory_tensor(sg.flash_tensor, ps.ifm2_tensor) - sg.command_stream_tensor = make_memory_tensor( sg.name + "_command_stream", flash_area, MemType.Permanent_CPU, command_stream_size_bytes, True, arch ) diff --git a/ethosu/vela/register_command_stream_generator.py b/ethosu/vela/register_command_stream_generator.py index ad29dae7..f9253691 100644 --- a/ethosu/vela/register_command_stream_generator.py +++ b/ethosu/vela/register_command_stream_generator.py @@ -58,6 +58,7 @@ from .architecture_features import Block from .architecture_features import create_default_arch from .architecture_features import SharedBufferArea from .architecture_features import SHRAMElements +from .errors import VelaError from .ethos_u55_regs.ethos_u55_regs import acc_format from .ethos_u55_regs.ethos_u55_regs import activation from .ethos_u55_regs.ethos_u55_regs import cmd0 @@ -944,6 +945,13 @@ def generate_command_stream( # Fill in final part of command stream: emit.cmd_do_operation(cmd0.NPU_OP_STOP, param=0xFFFF) res = emit.to_list() + + if emit.size_in_bytes() >= 1 << 24: + raise VelaError( + f"The command stream size exceeds the hardware limit of 16 MiB. " + f"The current stream size is {emit.size_in_bytes()/2**20:.2F} MiB." + ) + if verbose: emit.print_cmds() print("number of commands", len(emit.cmd_stream)) |