From 98b3e33a5590c3ff11f156997f8f2c45d8dc48e0 Mon Sep 17 00:00:00 2001 From: Kevin Petit Date: Tue, 16 May 2023 09:13:50 +0100 Subject: Replace uint6_t with int8_t Add REQUIRE statements to constrain the range where needed. Also fix a typo. Change-Id: I281e6249d8951b4cb3ff19eaf199660bed3feac9 Signed-off-by: Kevin Petit --- chapters/enumerations.adoc | 2 +- chapters/ewise_binary.adoc | 3 ++- chapters/introduction.adoc | 8 ++++---- tosa.xml | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/chapters/enumerations.adoc b/chapters/enumerations.adoc index 24a1708..9ef6dce 100644 --- a/chapters/enumerations.adoc +++ b/chapters/enumerations.adoc @@ -11,6 +11,6 @@ Where enumerated types are specified for an operator, the provided value must be a valid enumerant for that type. The included tables provide reference values for the enumerations. -Implementations do not need to use these values, they may subtitue other values as long as they are functionally equivalent. +Implementations do not need to use these values, they may substitute other values as long as they are functionally equivalent. include::{generated}/enums.adoc[] diff --git a/chapters/ewise_binary.adoc b/chapters/ewise_binary.adoc index 4af347a..864cf5b 100644 --- a/chapters/ewise_binary.adoc +++ b/chapters/ewise_binary.adoc @@ -297,8 +297,9 @@ include::{generated}/operators/MUL.adoc[] [source,c++] ---- +REQUIRE(0 <= shift && shift <= 63); +REQUIRE(in_t == int32_t || shift == 0); ERROR_IF(shape != broadcast_shape(shape1, shape2)); -ERROR_IF(in_t != int32_t && shift > 0); for_each(index in shape) { dim_t index1 = apply_broadcast(shape, shape1, index); dim_t index2 = apply_broadcast(shape, shape2, index); diff --git a/chapters/introduction.adoc b/chapters/introduction.adoc index 66bc9bf..c0b0874 100644 --- a/chapters/introduction.adoc +++ b/chapters/introduction.adoc @@ -544,7 +544,7 @@ The values to achieve a scaling of 1.0 are shift=30, multiplier=1<<30 for apply_ [source,c++] ---- -int32_t apply_scale_32(int32_t value, int32_t multiplier, uint6_t shift, bool_t double_round=false) { +int32_t apply_scale_32(int32_t value, int32_t multiplier, int8_t shift, bool_t double_round=false) { REQUIRE(multiplier >= 0); REQUIRE(2 <= shift && shift <= 62); REQUIRE(value >= (-1 << (shift - 1)) && value < (1 << (shift - 1)); @@ -559,7 +559,7 @@ int32_t apply_scale_32(int32_t value, int32_t multiplier, uint6_t shift, bool_t return (int32_t)result; } -int32_t apply_scale_16(int48_t value, int16_t multipler, uint6_t shift) { +int32_t apply_scale_16(int48_t value, int16_t multipler, int8_t shift) { REQUIRE(multiplier >= 0); REQUIRE(2 <= shift && shift <= 62); int64_t round = (1 << (shift - 1)); @@ -576,7 +576,7 @@ In some functions, the multiplier and shift are combined into a scale_t structur ---- typedef struct { int32_t multiplier; - uint6_t shift; + int8_t shift; } scale_t; ---- @@ -652,4 +652,4 @@ void generate_lookup_table(int16_t *table, int32_t (*reference)(int32_t)) The following publications are referred to in this specification, or provide more information: -. IEEE Std 754-2008, _IEEE Standard for Floating-point Arithmetic_, August 2008. \ No newline at end of file +. IEEE Std 754-2008, _IEEE Standard for Floating-point Arithmetic_, August 2008. diff --git a/tosa.xml b/tosa.xml index c11ad99..430f5fd 100644 --- a/tosa.xml +++ b/tosa.xml @@ -1052,7 +1052,7 @@ Input tensor with the same rank as input1 - + Result right shift (int32_t data type only) @@ -2338,7 +2338,7 @@ used. Scaling multiplier array - + Scaling shift array -- cgit v1.2.1