diff options
author | Tim Hall <tim.hall@arm.com> | 2020-10-20 18:54:20 +0100 |
---|---|---|
committer | Tim Hall <tim.hall@arm.com> | 2020-10-21 15:23:33 +0100 |
commit | 4ed38bce498e1b9a5ae917316323de444792521a (patch) | |
tree | f3721d7131eeafa14c33cf0339d579de99a3c66a /ethosu/vela/register_command_stream_generator.py | |
parent | 9358296a51b9186335304a53bd7ea5dfbe5322d8 (diff) | |
download | ethos-u-vela-4ed38bce498e1b9a5ae917316323de444792521a.tar.gz |
vela: Refactor operators to use Kernel objects
- Normalise kernel availability by requiring all operators offer a kernel
describing how much data they consume from the source, per OFM element,
regardless of whether kernels are relevant to the operation.
Signed-off-by: Tim Hall <tim.hall@arm.com>
Change-Id: Idbcff64879fc2eccf292b6208a7d2038eb388017
Diffstat (limited to 'ethosu/vela/register_command_stream_generator.py')
-rw-r--r-- | ethosu/vela/register_command_stream_generator.py | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/ethosu/vela/register_command_stream_generator.py b/ethosu/vela/register_command_stream_generator.py index 4f3fe7d4..0abd8828 100644 --- a/ethosu/vela/register_command_stream_generator.py +++ b/ethosu/vela/register_command_stream_generator.py @@ -27,7 +27,6 @@ import numpy as np from . import scaling from .architecture_features import ArchitectureFeatures from .architecture_features import Block -from .architecture_features import Kernel from .architecture_features import Rect from .architecture_features import SharedBufferArea from .architecture_features import SHRAMElements @@ -239,26 +238,6 @@ def get_cmd_wait_dependency(arch, cmd_stream, memory_accesses, cmd_index, waterm return watermark, outstanding -def get_op_kernel(ps): - if ps.primary_op is None: - return None - - strides = ps.primary_op.attrs.get("strides", (1, 1, 1, 1)) - dilation = ps.primary_op.attrs.get("dilation", (1, 1, 1, 1)) - if ps.weight_tensor: - if ps.npu_block_type in set((NpuBlockType.VectorProduct, NpuBlockType.ElementWise)): - k_h = 1 - k_w = 1 - else: - k_h = ps.weight_tensor.shape[0] - k_w = ps.weight_tensor.shape[1] - else: - k_h = ps.primary_op.attrs.get("filter_height", 1) - k_w = ps.primary_op.attrs.get("filter_width", 1) - - return Kernel(k_w, k_h, strides[2], strides[1], dilation[2], dilation[1]) - - def has_prev_op_dependency(prev_cmd, cmd): if prev_cmd is None: return False @@ -462,7 +441,7 @@ def generate_register_command_stream(nng, sg, arch, verbose=False): prev_ofm_rect = cur_ofm_rect prev_ofm_block = cur_ofm_block prev_kernel = cur_kernel - cur_kernel = get_op_kernel(ps) + cur_kernel = ps.primary_op.kernel if ps.primary_op else None block_config = ps.block_config emit.cmd0_with_param(cmd0.NPU_SET_OFM_BLK_HEIGHT_M1, block_config[0] - 1) @@ -585,7 +564,8 @@ def generate_register_command_stream(nng, sg, arch, verbose=False): # Set IFM2_IB_START to the latter half of the IB space ifm_ib_start = shared_buffer.bank_locations[SharedBufferArea.IFM] emit.cmd0_with_param( - cmd0.NPU_SET_IFM2_IB_START, (shram_required - ifm_ib_start) // shared_buffer.ifm_count + ifm_ib_start + cmd0.NPU_SET_IFM2_IB_START, + (shram_required - ifm_ib_start) // shared_buffer.ifm_count + ifm_ib_start, ) emit.cmd0_with_param(cmd0.NPU_SET_IFM2_BROADCAST, ifm2_broadcast) |