aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic Symes <dominic.symes@arm.com>2022-04-29 16:15:56 +0100
committerDominic Symes <dominic.symes@arm.com>2022-05-03 13:36:22 +0000
commitcb6c6b33cc85d6c40d46b1ee78bcbd6a049017d5 (patch)
tree94988082f976e28f25cc13c0331efd119f83b3f2
parent5de08d1db3c1de4fddf3f4bb7a286db35cb9f9d1 (diff)
downloadspecification-cb6c6b33cc85d6c40d46b1ee78bcbd6a049017d5.tar.gz
Specify width of integer types
Clarify for types previously definded as int the width assumed by the specification. Signed-off-by: Dominic Symes <dominic.symes@arm.com> Change-Id: Ied62d4803a4323a600d33cff09752a76ca48f18d
-rw-r--r--chapters/activation_funcs.adoc4
-rw-r--r--chapters/control_flow.adoc2
-rw-r--r--chapters/data_layout.adoc12
-rw-r--r--chapters/image.adoc10
-rw-r--r--chapters/introduction.adoc2
-rw-r--r--chapters/pseudocode.adoc10
6 files changed, 20 insertions, 20 deletions
diff --git a/chapters/activation_funcs.adoc b/chapters/activation_funcs.adoc
index 84a1039..87f213c 100644
--- a/chapters/activation_funcs.adoc
+++ b/chapters/activation_funcs.adoc
@@ -58,7 +58,7 @@ The sigmoid table has 513 entries each of 16-bit precision and covering the inpu
[source,c++]
----
-int sigmoid_reference(int x) {|// input x range is -256 to + 256 inclusive
+int16_t sigmoid_reference(int16_t x) { // input x range is -256 to + 256 inclusive
F64 v = (double)x / (double)16;
v = 1.0/(1.0 + exp(-v));
return round_to_nearest_int(32768.0 * v);
@@ -95,7 +95,7 @@ The tanh_table has 513 entries each of 16-bit precision and covering the input r
[source,c++]
----
-int tanh_reference(int x) { // input x range is -256 to +256 inclusive
+int16_t tanh_reference(int16_t x) { // input x range is -256 to +256 inclusive
F64 v = (double)x/(double)32;
v = exp(-2.0*v);
v = (1.0-v)/(1.0+v);
diff --git a/chapters/control_flow.adoc b/chapters/control_flow.adoc
index c9d4e15..e3c7fad 100644
--- a/chapters/control_flow.adoc
+++ b/chapters/control_flow.adoc
@@ -70,7 +70,7 @@ ERROR_IF(tosa_output_shape(cond_graph) != tosa_list_shape([bool_t]));
// The iteration number 'i' is included to give unique names to variables
// in each iteration of the loop and is not required by implementations
-int i=0; // iteration number
+int32_t i=0; // iteration number
list[i] = input_list; // copy input data as list[0]
tosa_execute_graph(cond_graph, list[i], [condition[i]]); // initial condition
while (condition[i]) {
diff --git a/chapters/data_layout.adoc b/chapters/data_layout.adoc
index 08eda29..246a0f6 100644
--- a/chapters/data_layout.adoc
+++ b/chapters/data_layout.adoc
@@ -19,7 +19,7 @@ No data conversion happens during a concat operation.
|Argument|Type|Name|Shape|Description
|Input|in_out_t*|input1|shapes1[]|List of input tensors. All inputs must have the same rank and data type
-|Attribute|int|axis|-|Axis along which concatenation is to occur, in range from 0 to rank(shape)-1
+|Attribute|int32_t|axis|-|Axis along which concatenation is to occur, in range from 0 to rank(shape)-1
|Output|in_out_t*|output|shape|Output tensor
|===
@@ -76,7 +76,7 @@ The pad_const value includes the zero point if the tensor uses a zero point.
|Argument|Type|Name|Shape|Description
|Input|in_out_t*|input1|shape1|Input tensor
-|Attribute|int|padding|[rank(input1),2]|Amount of padding to be done
+|Attribute|int32_t|padding|[rank(input1),2]|Amount of padding to be done
|Attribute|in_out_t|pad_const|-|Constant value to be used as padding
|Output|in_out_t*|output|shape|Output tensor of same type as the input tensor
|===
@@ -125,7 +125,7 @@ Returns a tensor with the same type/values as the input, with a new shape specif
|Argument|Type|Name|Shape|Description
|Input|in_out_t*|input1|shape1|Input tensor
-|Attribute|int|new_shape|[rank(output)]|List of values, with each element giving the size of the result tensor for the given dimension. At most one dimension may be given as -1 to automatically calculate the dimension size.
+|Attribute|int32_t|new_shape|[rank(output)]|List of values, with each element giving the size of the result tensor for the given dimension. At most one dimension may be given as -1 to automatically calculate the dimension size.
|Output|in_out_t*|output|shape|Output tensor of same type, size as the input tensor
|===
@@ -161,7 +161,7 @@ Returns a tensor with the same type/values as the input, with the data reversed
|Argument|Type|Name|Shape|Description
|Input|in_out_t*|input|shape|Input tensor from 1 to 4 dims
-|Attribute|int|axis|-|Axis to reverse, in range from 0 to rank(shape)-1
+|Attribute|int32_t|axis|-|Axis to reverse, in range from 0 to rank(shape)-1
|Output|in_out_t*|output|shape|Output tensor. Same shape as input tensor.
|===
@@ -200,8 +200,8 @@ No data conversion happens during a slice operation.
|Argument|Type|Name|Shape|Description
|Input|in_out_t*|input1|shape1|Input tensor with rank from 1 to 4
-|Attribute|int|start|[rank(input1)]|List of integer coordinates, of length equal to the rank of input1. Start coordinate for slicing.
-|Attribute|int|size|[rank(input1)]|List of integer size values, of length equal to the rank of input1. Size of the input to be used.
+|Attribute|int32_t|start|[rank(input1)]|List of integer coordinates, of length equal to the rank of input1. Start coordinate for slicing.
+|Attribute|int32_t|size|[rank(input1)]|List of integer size values, of length equal to the rank of input1. Size of the input to be used.
|Output|in_out_t*|output|shape|Output tensor of same type as the input tensor
|===
diff --git a/chapters/image.adoc b/chapters/image.adoc
index 039595e..c25e2ec 100644
--- a/chapters/image.adoc
+++ b/chapters/image.adoc
@@ -53,11 +53,11 @@ input position (IH-1,IW-1).
|Argument|Type|Name|Shape|Description
|Input|in_t*|input|[N,IH,IW,C]|Input tensor
-|Attribute|int*|output_size|[2]|[OH,OW]
+|Attribute|int32_t* |output_size|[2]|[OH,OW]
|Attribute|resize_t*|stride|[2]|[stride_y, stride_x]
|Attribute|resize_t*|offset|[2]|[offset_y, offset_x]
-|Attribute|int* |border|[2]|[border_y, border_x]
-|Attribute|int |shift|-|Shift value (must be zero if resize_t is float)
+|Attribute|int32_t* |border|[2]|[border_y, border_x]
+|Attribute|int32_t |shift|-|Shift value (must be zero if resize_t is float)
|Attribute|mode_t|mode|-|BILINEAR or NEAREST
|Output|out_t*|output|[N,OH,OW,C]|Output tensor
|===
@@ -94,8 +94,8 @@ for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW; 0 <= c < C) {
y = oy * stride_y + offset_y;
x = ox * stride_x + offset_x;
if (resize_t == float_t) {
- iy = (int)apply_floor(y); dy = y - (float_t)iy;
- ix = (int)apply_floor(x); dx = x - (float_t)ix;
+ iy = (int32_t)apply_floor(y); dy = y - (float_t)iy;
+ ix = (int32_t)apply_floor(x); dx = x - (float_t)ix;
} else {
iy = y >> shift; dy = y - (iy<<shift);
ix = x >> shift; dx = x - (ix<<shift);
diff --git a/chapters/introduction.adoc b/chapters/introduction.adoc
index fe4f724..4263135 100644
--- a/chapters/introduction.adoc
+++ b/chapters/introduction.adoc
@@ -405,7 +405,7 @@ In places where a divide is required, we also use the function below to calculat
scale_t reciprocal_scale(uint32_t value) {
REQUIRE(value > 0);
scale_t scale;
- int k = 32 - count_leading_zeros(value - 1); // (1 << k) / 2 < value <= (1 << k)
+ int32_t k = 32 - count_leading_zeros(value - 1); // (1 << k) / 2 < value <= (1 << k)
int64_t numerator = ((1 << 30) + 1) << k;
scale.multiplier = numerator / value; // (1 << 30) <= multiplier < (1 << 31)
scale.shift = 30 + k;
diff --git a/chapters/pseudocode.adoc b/chapters/pseudocode.adoc
index 3f885c7..a370880 100644
--- a/chapters/pseudocode.adoc
+++ b/chapters/pseudocode.adoc
@@ -181,24 +181,24 @@ Generic helper functions used to keep the pseudocode concise.
[source,c++]
----
-int idiv(int input1, int input2) {
+int32_t idiv(int32_t input1, int32_t input2) {
return input1 / input2; // Integer divide that truncates towards zero
}
// Integer division that checks input1 is a multiple of input2
-int idiv_check(int input1, int input2) {
+int32_t idiv_check(int32_t input1, int32_t input2) {
ERROR_IF(input1 % input2 != 0); // input1 must be a multiple of input2
return input1 / input2; // exact quotient without rounding
}
-int length(in_t input)
+int32_t length(in_t input)
return number of elements in input list
-int rank(in_t input)
+int32_t rank(in_t input)
return rank of an input tensor
-int sum(in_t input[])
+int32_t sum(in_t input[])
return the sum of values of an input list
bool isNaN(float input)