aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Petit <kevin.petit@arm.com>2024-02-08 11:03:31 +0000
committerKevin Petit <kevin.petit@arm.com>2024-02-23 18:34:06 +0000
commitafaaa673e1620315e0d7d863d7bcef1a2dc54df9 (patch)
treebdba3f5658083c12694ae28448ed8551039ced6d
parent0635552aed54eee35ca417901b65754a07a12dae (diff)
downloadspecification-afaaa673e1620315e0d7d863d7bcef1a2dc54df9.tar.gz
pseudocode: a collection of variable declaration fixes
Only cases where types are obvious. - Add missing types - Do not re-declare variables - Fix scope of declaration Signed-off-by: Kevin Petit <kevin.petit@arm.com> Change-Id: I7d44d9adde606094e0a7910fb438649521ff3ec0
-rw-r--r--pseudocode/operators/COS.tosac2
-rw-r--r--pseudocode/operators/PAD.tosac4
-rw-r--r--pseudocode/operators/RESCALE.tosac13
-rw-r--r--pseudocode/operators/SIGMOID.tosac2
-rw-r--r--pseudocode/operators/SIN.tosac2
-rw-r--r--pseudocode/operators/SLICE.tosac2
-rw-r--r--pseudocode/operators/TANH.tosac2
-rw-r--r--pseudocode/operators/TILE.tosac2
-rw-r--r--pseudocode/operators/TRANSPOSE.tosac4
-rw-r--r--pseudocode/operators/VARIABLE.tosac2
10 files changed, 18 insertions, 17 deletions
diff --git a/pseudocode/operators/COS.tosac b/pseudocode/operators/COS.tosac
index e1f1d91..afb9d14 100644
--- a/pseudocode/operators/COS.tosac
+++ b/pseudocode/operators/COS.tosac
@@ -9,6 +9,6 @@
for_each(index in shape) {
in_out_t value1 = tensor_read<in_out_t>(input, shape, index);
- value = cos<in_out_t>(value1);
+ in_out_t value = cos<in_out_t>(value1);
tensor_write<in_out_t>(output, shape, index, value);
}
diff --git a/pseudocode/operators/PAD.tosac b/pseudocode/operators/PAD.tosac
index 45ef674..b458170 100644
--- a/pseudocode/operators/PAD.tosac
+++ b/pseudocode/operators/PAD.tosac
@@ -9,14 +9,14 @@
// Check output shape matches the padded input shape
ERROR_IF(rank(shape) != rank(shape1));
-for (i = 0; i < rank(shape); i++) {
+for (int32_t i = 0; i < rank(shape); i++) {
ERROR_IF(padding[i * 2] < 0 || padding[(i * 2) + 1] < 0);
ERROR_IF(shape[i] != padding[i * 2] + shape1[i] + padding[(i * 2) + 1]);
}
for_each(index in shape) {
shape_t index1 = index;
bool_t is_pad = false;
- for(i = 0; i < rank(shape); i++) {
+ for(int32_t i = 0; i < rank(shape); i++) {
index1[i] = index1[i] - padding[i * 2];
if (index1[i] < 0 || index[i] >= length(shape[i])) {
is_pad = true;
diff --git a/pseudocode/operators/RESCALE.tosac b/pseudocode/operators/RESCALE.tosac
index 0a3ce8d..555d4ca 100644
--- a/pseudocode/operators/RESCALE.tosac
+++ b/pseudocode/operators/RESCALE.tosac
@@ -42,19 +42,20 @@ for_each(index in shape) {
apply_scale_32(value, multiplier[c], shift[c], double_round) :
apply_scale_16(value, multiplier[c], shift[c]);
+ out_t out;
if (output_unsigned) {
int32_t extended_out_zp = zero_extend<int32_t>(output_zp);
result = apply_add_s<int32_t>(result, extended_out_zp);
- out_t out = static_cast<out_t>(apply_clip_u<i32_t>(result,
- minimum_u<out_t>(),
- maximum_u<out_t>()));
+ out = static_cast<out_t>(apply_clip_u<i32_t>(result,
+ minimum_u<out_t>(),
+ maximum_u<out_t>()));
}
else {
int32_t extended_out_zp = sign_extend<int32_t>(output_zp);
result = apply_add_s<int32_t>(result, extended_out_zp);
- out_t out = static_cast<out_t>(apply_clip_s<i32_t>(result,
- minimum_s<out_t>(),
- maximum_s<out_t>()));
+ out = static_cast<out_t>(apply_clip_s<i32_t>(result,
+ minimum_s<out_t>(),
+ maximum_s<out_t>()));
}
tensor_write<out_t>(output, shape, index, out);
}
diff --git a/pseudocode/operators/SIGMOID.tosac b/pseudocode/operators/SIGMOID.tosac
index 048523e..fd9afc7 100644
--- a/pseudocode/operators/SIGMOID.tosac
+++ b/pseudocode/operators/SIGMOID.tosac
@@ -9,6 +9,6 @@
for_each(index in shape) {
in_out_t value1 = tensor_read<in_out_t>(input, shape, index);
- value = sigmoid<in_out_t>(value1);
+ in_out_t value = sigmoid<in_out_t>(value1);
tensor_write<in_out_t>(output, shape, index, value);
}
diff --git a/pseudocode/operators/SIN.tosac b/pseudocode/operators/SIN.tosac
index 9a24a00..82361a9 100644
--- a/pseudocode/operators/SIN.tosac
+++ b/pseudocode/operators/SIN.tosac
@@ -9,6 +9,6 @@
for_each(index in shape) {
in_out_t value1 = tensor_read<in_out_t>(input, shape, index);
- value = sin<in_out_t>(value1);
+ in_out_t value = sin<in_out_t>(value1);
tensor_write<in_out_t>(output, shape, index, value);
}
diff --git a/pseudocode/operators/SLICE.tosac b/pseudocode/operators/SLICE.tosac
index b6f70c5..b7b0680 100644
--- a/pseudocode/operators/SLICE.tosac
+++ b/pseudocode/operators/SLICE.tosac
@@ -20,7 +20,7 @@ for_each(index in rank(shape1)) {
for_each(index in shape) {
shape_t tmp_index = index;
- for(i = 0; i < rank(shape); i++) {
+ for(int32_t i = 0; i < rank(shape); i++) {
tmp_index[i] = index[i] + start[i];
}
in_out_t value = tensor_read<in_out_t>(input1, shape1, tmp_index);
diff --git a/pseudocode/operators/TANH.tosac b/pseudocode/operators/TANH.tosac
index 1b5edba..c0dccc1 100644
--- a/pseudocode/operators/TANH.tosac
+++ b/pseudocode/operators/TANH.tosac
@@ -9,6 +9,6 @@
for_each(index in shape) {
in_out_t value1 = tensor_read<in_out_t>(input, shape, index);
- value = tanh<in_out_t>(value1);
+ in_out_t value = tanh<in_out_t>(value1);
tensor_write<in_out_t>(output, shape, index, value);
}
diff --git a/pseudocode/operators/TILE.tosac b/pseudocode/operators/TILE.tosac
index be1cfee..5ebd1c1 100644
--- a/pseudocode/operators/TILE.tosac
+++ b/pseudocode/operators/TILE.tosac
@@ -11,7 +11,7 @@ ERROR_IF(rank(shape1) != rank(shape));
for_each(index in shape) {
shape_t tmp_index = index;
- for(i = 0; i < rank(shape); i++) {
+ for(int32_t i = 0; i < rank(shape); i++) {
ERROR_IF(shape1[i] * multiples[i] != shape[i]);
tmp_index[i] = index[i] % shape1[i];
}
diff --git a/pseudocode/operators/TRANSPOSE.tosac b/pseudocode/operators/TRANSPOSE.tosac
index 3981f54..09fea65 100644
--- a/pseudocode/operators/TRANSPOSE.tosac
+++ b/pseudocode/operators/TRANSPOSE.tosac
@@ -21,13 +21,13 @@ for_each(index in perms) {
// Ensure that the output shapes have the properly
// permuted shapes
-for(i = 0; i < rank(shape); i++) {
+for(int32_t i = 0; i < rank(shape); i++) {
ERROR_IF(shape1[perms[i]] != shape[i]);
}
for_each(index in shape) {
shape_t tmp_index = index;
- for(i = 0; i < rank(shape); i++) {
+ for(int32_t i = 0; i < rank(shape); i++) {
tmp_index[perms[i]] = index[i];
}
in_out_t value = tensor_read<in_out_t>(input1, shape1, tmp_index);
diff --git a/pseudocode/operators/VARIABLE.tosac b/pseudocode/operators/VARIABLE.tosac
index 4d2fce7..aaa2155 100644
--- a/pseudocode/operators/VARIABLE.tosac
+++ b/pseudocode/operators/VARIABLE.tosac
@@ -13,7 +13,7 @@ tensor_t var_tensor = variable_tensor_lookup(uid);
// Invocation for the first time
if (var_tensor == NULL) {
// Allocate the persistent mutable memory for the variable tensor
- tensor_t var_tensor = variable_tensor_allocate<var_t>(var_shape, uid);
+ var_tensor = variable_tensor_allocate<var_t>(var_shape, uid);
if (initial_value != NULL) {
REQUIRE(var_t == in_t);