aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Petit <kevin.petit@arm.com>2024-02-08 10:29:43 +0000
committerKevin Petit <kevin.petit@arm.com>2024-02-08 10:29:43 +0000
commit599de076047aae846fd28cc52a777e4b6e534aaf (patch)
treeb8eab10e9cab319d9023b141480e2cd82486c0af
parentc65cd9ccff6000be01ee0742319009f0061879ce (diff)
downloadspecification-599de076047aae846fd28cc52a777e4b6e534aaf.tar.gz
pseudocode: use function call syntax to call templated functions
Change-Id: I24409a38aaf4818a9ab0abc0cad5c7d052e01bd1 Signed-off-by: Kevin Petit <kevin.petit@arm.com>
-rw-r--r--pseudocode/library/arithmetic_helpers.tosac24
-rw-r--r--pseudocode/operators/ABS.tosac2
-rw-r--r--pseudocode/operators/ARGMAX.tosac2
-rw-r--r--pseudocode/operators/ARITHMETIC_RIGHT_SHIFT.tosac2
-rw-r--r--pseudocode/operators/AVG_POOL2D.tosac2
-rw-r--r--pseudocode/operators/INTDIV.tosac2
-rw-r--r--pseudocode/operators/MUL.tosac2
-rw-r--r--pseudocode/operators/NEGATE.tosac4
-rw-r--r--pseudocode/operators/REDUCE_MIN.tosac2
-rw-r--r--pseudocode/operators/RESCALE.tosac8
-rw-r--r--pseudocode/operators/RESIZE.tosac8
11 files changed, 29 insertions, 29 deletions
diff --git a/pseudocode/library/arithmetic_helpers.tosac b/pseudocode/library/arithmetic_helpers.tosac
index be82ef5..1b8de0f 100644
--- a/pseudocode/library/arithmetic_helpers.tosac
+++ b/pseudocode/library/arithmetic_helpers.tosac
@@ -8,16 +8,16 @@
// by a licensing agreement from ARM Limited.
in_t apply_add_s<in_t>(in_t a, in_t b) {
- if (is_floating_point(in_t)) return a + b;
+ if (is_floating_point<in_t>()) return a + b;
int64_t c = sign_extend<int64_t>(a) + sign_extend<int64_t>(b);
- REQUIRE(c >= minimum_s<in_t> && c <= maximum_s<in_t>);
+ REQUIRE(c >= minimum_s<in_t>() && c <= maximum_s<in_t>());
return static_cast<in_t>(c);
}
in_t apply_add_u<in_t>(in_t a, in_t b) {
- if (is_floating_point(in_t)) return a + b;
+ if (is_floating_point<in_t>()) return a + b;
uint64_t c = zero_extend<uint64_t>(a) + zero_extend<uint64_t>(b);
- REQUIRE(c >= minimum_u<in_u_t> && c <= maximum_u<in_u_t>);
+ REQUIRE(c >= minimum_u<in_u_t>() && c <= maximum_u<in_u_t>());
return truncate<in_t>(c);
}
@@ -28,7 +28,7 @@ in_t apply_arith_rshift<in_t>(in_t a, in_t b) {
in_t apply_intdiv_s<in_t>(in_t a, in_t b) {
int64_t c = sign_extend<int64_t>(a) / sign_extend<int64_t>(b);
- REQUIRE(c >= minimum_s<in_t> && c <= maximum_s<in_t>);
+ REQUIRE(c >= minimum_s<in_t>() && c <= maximum_s<in_t>());
return static_cast<in_t>(c);
}
@@ -37,7 +37,7 @@ in_t apply_ceil<in_t>(in_t input) {
}
in_t apply_clip_s<in_t>(in_t value, in_t min_val, in_t max_val) {
- if (is_floating_point(in_t>) {
+ if (is_floating_point<in_t>()) {
REQUIRE(min_val <= max_val);
}
else {
@@ -79,7 +79,7 @@ in_t apply_logical_rshift<in_t>(in_t a, in_t b) {
}
in_t apply_max_s<in_t>(in_t a, in_t b) {
- if (is_floating_point(in_t)) {
+ if (is_floating_point<in_t>()) {
if (isNaN(a) || isNaN(b)) {
return NaN;
}
@@ -94,7 +94,7 @@ in_t apply_max_u<in_t>(in_t a, in_t b) {
}
in_t apply_min_s<in_t>(in_t a, in_t b) {
- if (is_floating_point(in_t)) {
+ if (is_floating_point<in_t>()) {
if (isNaN(a) || isNaN(b)) {
return NaN;
}
@@ -109,7 +109,7 @@ in_t apply_min_u<in_t>(in_t a, in_t b) {
}
in_t apply_mul_s<in_t>(in_t a, in_t b) {
- if (is_floating_point(in_t)) return a * b;
+ if (is_floating_point<in_t>()) return a * b;
int64_t c = sign_extend<int64_t>(a) * sign_extend<int64_t>(b);
return static_cast<in_t>(c);
}
@@ -123,15 +123,15 @@ in_t apply_sqrt<in_t>(in_t input) {
}
in_t apply_sub_s<in_t>(in_t a, in_t b) {
- if (is_floating_point(in_t)) return a - b;
+ if (is_floating_point<in_t>()) return a - b;
int64_t c = sign_extend<int64_t>(a) - sign_extend<int64_t>(b);
- REQUIRE(c >= minimum_s<in_t> && c <= maximum_s<in_t>);
+ REQUIRE(c >= minimum_s<in_t>() && c <= maximum_s<in_t>());
return static_cast<in_t>(c);
}
in_t apply_sub_u<in_t>(in_t a, in_t b) {
uint64_t c = zero_extend<uint64_t>(a) - zero_extend<uint64_t>(b);
- REQUIRE(c >= minimum_u<in_u_t> && c <= maximum_u<in_u_t>);
+ REQUIRE(c >= minimum_u<in_u_t>() && c <= maximum_u<in_u_t>());
return truncate<in_t>(c);
}
diff --git a/pseudocode/operators/ABS.tosac b/pseudocode/operators/ABS.tosac
index 5f7f56e..94f439c 100644
--- a/pseudocode/operators/ABS.tosac
+++ b/pseudocode/operators/ABS.tosac
@@ -9,7 +9,7 @@
for_each(index in shape) {
in_out_t value1 = tensor_read<in_out_t>(input1, shape, index);
- if (is_floating_point(in_out_t) && value1 == -0.0) {
+ if (is_floating_point<in_out_t>() && value1 == -0.0) {
value1 = 0.0;
}
if (static_cast<int32_t>(value1) < 0.0) {
diff --git a/pseudocode/operators/ARGMAX.tosac b/pseudocode/operators/ARGMAX.tosac
index 73b74a0..ac7aa7a 100644
--- a/pseudocode/operators/ARGMAX.tosac
+++ b/pseudocode/operators/ARGMAX.tosac
@@ -21,7 +21,7 @@ if (axis == rank(shape1)-1) {
ERROR_IF(flatten(left_shape, right_shape) != shape);
for_each(left_index in left_shape) {
for_each(right_index in right_shape) {
- in_t max_value = minimum_s<in_t>;
+ in_t max_value = minimum_s<in_t>();
out_t max_index = 0;
for (i = 0; i < shape1[axis]; i++) {
shape_t index = flatten(left_index, [i], right_index);
diff --git a/pseudocode/operators/ARITHMETIC_RIGHT_SHIFT.tosac b/pseudocode/operators/ARITHMETIC_RIGHT_SHIFT.tosac
index dd07fc5..36d01ed 100644
--- a/pseudocode/operators/ARITHMETIC_RIGHT_SHIFT.tosac
+++ b/pseudocode/operators/ARITHMETIC_RIGHT_SHIFT.tosac
@@ -24,6 +24,6 @@ for_each(index in shape) {
(apply_arith_rshift<in_out_t>(value1, apply_sub_s<in_out_t>(value2, 1)) & 1 != 0)) {
result = result + 1;
}
- result = apply_clip_s<in_out_t>(result, minimum_s<in_out_t>, maximum_s<in_out_t>);
+ result = apply_clip_s<in_out_t>(result, minimum_s<in_out_t>(), maximum_s<in_out_t>());
tensor_write<in_out_t>(output, shape, index, result);
}
diff --git a/pseudocode/operators/AVG_POOL2D.tosac b/pseudocode/operators/AVG_POOL2D.tosac
index f452d12..6df313b 100644
--- a/pseudocode/operators/AVG_POOL2D.tosac
+++ b/pseudocode/operators/AVG_POOL2D.tosac
@@ -43,7 +43,7 @@ for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW, 0 <= c < C ) {
scale_t scale = reciprocal_scale(count);
acc = apply_scale_32(acc, scale.multiplier, scale.shift, false);
acc = apply_add_s<acc_t>(acc, sign_extend<acc_t>(output_zp));
- acc = apply_clip_s<acc_t>(acc, minimum_s<in_out_t>, maximum_s<in_out_t>);
+ acc = apply_clip_s<acc_t>(acc, minimum_s<in_out_t>(), maximum_s<in_out_t>());
output_val = static_cast<in_out_t>(acc);
}
tensor_write<in_out_t>(output, [N,OH,OW,C], [n,oy,ox,c], output_val);
diff --git a/pseudocode/operators/INTDIV.tosac b/pseudocode/operators/INTDIV.tosac
index bf3126b..a6774fa 100644
--- a/pseudocode/operators/INTDIV.tosac
+++ b/pseudocode/operators/INTDIV.tosac
@@ -16,7 +16,7 @@ for_each(index in shape) {
REQUIRE(value2 != 0);
// This catches the case where we divide minimum<in_out_t> by -1
// which is not representable in two's complement
- REQUIRE(static_cast<int64_t>(value1) / static_cast<int64_t>(value2) <= maximum_s<in_out_t>);
+ REQUIRE(static_cast<int64_t>(value1) / static_cast<int64_t>(value2) <= maximum_s<in_out_t>());
in_out_t result = apply_intdiv_s<in_out_t>(value1, value2);
tensor_write<in_out_t>(output, shape, index, result);
}
diff --git a/pseudocode/operators/MUL.tosac b/pseudocode/operators/MUL.tosac
index 5cc9f80..13c4a17 100644
--- a/pseudocode/operators/MUL.tosac
+++ b/pseudocode/operators/MUL.tosac
@@ -20,7 +20,7 @@ for_each(index in shape) {
int64_t product = sign_extend<int64_t>(value1) * sign_extend<int64_t>(value2);
int64_t round = static_cast<int64_t>(1) << (shift - 1);
product = (product + round) >> shift;
- REQUIRE(product >= minimum_s<i32_t> && product <= maximum_s<i32_t>)
+ REQUIRE(product >= minimum_s<i32_t>() && product <= maximum_s<i32_t>())
result = product;
} else {
result = apply_mul_s(value1, value2); // low 32-bits of result for i32_t
diff --git a/pseudocode/operators/NEGATE.tosac b/pseudocode/operators/NEGATE.tosac
index cae57f3..b0f12d1 100644
--- a/pseudocode/operators/NEGATE.tosac
+++ b/pseudocode/operators/NEGATE.tosac
@@ -16,7 +16,7 @@ for_each(index in shape) {
value = apply_sub_s<acc_t>(0, value);
value = apply_add_s<acc_t>(value, sign_extend<acc_t>(output_zp));
in_out_t result = truncate<in_out_t>(apply_clip_s<acc_t>(value,
- minimum_s<in_out_t>,
- maximum_s<in_out_t>));
+ minimum_s<in_out_t>(),
+ maximum_s<in_out_t>()));
tensor_write<in_out_t>(output, shape, index, result);
}
diff --git a/pseudocode/operators/REDUCE_MIN.tosac b/pseudocode/operators/REDUCE_MIN.tosac
index 7e1f92d..437ecfd 100644
--- a/pseudocode/operators/REDUCE_MIN.tosac
+++ b/pseudocode/operators/REDUCE_MIN.tosac
@@ -13,7 +13,7 @@ left_shape = (axis > 1) ? shape[0:axis-1] : [];
right_shape = (axis < rank(shape)-1) ? shape[axis+1:rank(shape)-1] : [];
for_each(left_index in left_shape) {
for_each(right_index in right_shape) {
- in_out_t acc = maximum<in_out_t>;
+ in_out_t acc = maximum<in_out_t>();
for (i = 0; i < shape1[axis]; i++) {
index = flatten(left_index, [i], right_index);
in_out_t value = tensor_read<in_out_t>(input, shape1, index);
diff --git a/pseudocode/operators/RESCALE.tosac b/pseudocode/operators/RESCALE.tosac
index 3ebb8d6..b13a5ad 100644
--- a/pseudocode/operators/RESCALE.tosac
+++ b/pseudocode/operators/RESCALE.tosac
@@ -44,15 +44,15 @@ for_each(index in shape) {
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>));
+ 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>));
+ minimum_s<out_t>(),
+ maximum_s<out_t>()));
}
tensor_write<out_t>(output, shape, index, out);
}
diff --git a/pseudocode/operators/RESIZE.tosac b/pseudocode/operators/RESIZE.tosac
index 2a90f5f..96fcacb 100644
--- a/pseudocode/operators/RESIZE.tosac
+++ b/pseudocode/operators/RESIZE.tosac
@@ -26,8 +26,8 @@ for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW, 0 <= c < C) {
resize_t dx, dy;
resize_t unit_x, unit_y;
- unit_x = (is_floating_point(resize_t)) ? 1.0 : scale_x_n;
- unit_y = (is_floating_point(resize_t)) ? 1.0 : scale_y_n;
+ unit_x = (is_floating_point<resize_t>()) ? 1.0 : scale_x_n;
+ unit_y = (is_floating_point<resize_t>()) ? 1.0 : scale_y_n;
int32_t y = oy * scale_y_d + offset_y;
int32_t x = ox * scale_x_d + offset_x;
@@ -36,7 +36,7 @@ for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW, 0 <= c < C) {
int16_t ry = y - iy * scale_y_n; // (y % scale_y_n)
int16_t rx = x - ix * scale_x_n; // (x % scale_x_n)
- if (is_floating_point(resize_t)) {
+ if (is_floating_point<resize_t>()) {
dy = static_cast<resize_t>(ry) / static_cast<resize_t>(scale_y_n);
dx = static_cast<resize_t>(rx) / static_cast<resize_t>(scale_x_n);
} else {
@@ -61,7 +61,7 @@ for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW, 0 <= c < C) {
tensor_write<out_t>(output, [N,OH,OW,C], [n,oy,ox,c], acc);
} else if (mode==NEAREST) {
int32_t iy, ix;
- if (is_floating_point(resize_t)) {
+ if (is_floating_point<resize_t>()) {
iy = (dy >= 0.5) ? iy1 : iy0;
ix = (dx >= 0.5) ? ix1 : ix0;
} else {