diff options
author | Fredrik Svedberg <fredrik.svedberg@arm.com> | 2020-03-30 13:15:28 +0200 |
---|---|---|
committer | Tim Hall <tim.hall@arm.com> | 2020-06-18 17:53:52 +0100 |
commit | d67c0aaccd91f4be3ea76f69fa063301ffc73aa3 (patch) | |
tree | a9ad54b32d18685347847fcc59db8374bbe36233 /ethosu/vela/register_command_stream_generator.py | |
parent | fed918bfb26dc330a5f066ea5947bc5eb2db4651 (diff) | |
download | ethos-u-vela-d67c0aaccd91f4be3ea76f69fa063301ffc73aa3.tar.gz |
MLBEDSW-819: make int16 changes
Enabled int16 support quantization to match the reference.
Change-Id: Ib369640241a9a491f2b0bc52d7f6cb025e30344b
Signed-off-by: Fredrik Svedberg <fredrik.svedberg@arm.com>
Diffstat (limited to 'ethosu/vela/register_command_stream_generator.py')
-rw-r--r-- | ethosu/vela/register_command_stream_generator.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ethosu/vela/register_command_stream_generator.py b/ethosu/vela/register_command_stream_generator.py index faae2cf3..5fa71aa7 100644 --- a/ethosu/vela/register_command_stream_generator.py +++ b/ethosu/vela/register_command_stream_generator.py @@ -27,7 +27,7 @@ from .ethos_u55_regs.ethos_u55_regs import * from .tensor import MemArea, TensorBlockTraversal from .operation import NpuBlockType from .numeric_util import quantise_float32, round_up, round_away_zero, round_up_to_int, clamp_sigmoid, clamp_tanh -from .data_type import BaseType +from .data_type import BaseType, DataType import numpy as np from .shared_buffer_allocation import SharedBufferAllocation from .architecture_features import SharedBufferArea, SHRAMElements, ArchitectureFeatures @@ -615,6 +615,9 @@ def generate_register_command_stream(nng, sg, arch, verbose=False): else: # Convolution assert cmd.weight_tensor.block_traversal != TensorBlockTraversal.Default + # Reduced precision quantization and natural rounding used for int16 + if cmd.ifm_tensor.dtype == DataType.int16: + rounding_mode = rounding.NATURAL emit.cmd0_with_param(cmd0.NPU_SET_KERNEL_HEIGHT_M1, cmd.weight_tensor.shape[0] - 1) emit.cmd0_with_param(cmd0.NPU_SET_KERNEL_WIDTH_M1, cmd.weight_tensor.shape[1] - 1) if cmd.weight_tensor.block_traversal == TensorBlockTraversal.PartKernelFirst: |