From 599de076047aae846fd28cc52a777e4b6e534aaf Mon Sep 17 00:00:00 2001 From: Kevin Petit Date: Thu, 8 Feb 2024 10:29:43 +0000 Subject: pseudocode: use function call syntax to call templated functions Change-Id: I24409a38aaf4818a9ab0abc0cad5c7d052e01bd1 Signed-off-by: Kevin Petit --- pseudocode/library/arithmetic_helpers.tosac | 24 +++++++++++------------ pseudocode/operators/ABS.tosac | 2 +- pseudocode/operators/ARGMAX.tosac | 2 +- pseudocode/operators/ARITHMETIC_RIGHT_SHIFT.tosac | 2 +- pseudocode/operators/AVG_POOL2D.tosac | 2 +- pseudocode/operators/INTDIV.tosac | 2 +- pseudocode/operators/MUL.tosac | 2 +- pseudocode/operators/NEGATE.tosac | 4 ++-- pseudocode/operators/REDUCE_MIN.tosac | 2 +- pseudocode/operators/RESCALE.tosac | 8 ++++---- pseudocode/operators/RESIZE.tosac | 8 ++++---- 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 a, in_t b) { - if (is_floating_point(in_t)) return a + b; + if (is_floating_point()) return a + b; int64_t c = sign_extend(a) + sign_extend(b); - REQUIRE(c >= minimum_s && c <= maximum_s); + REQUIRE(c >= minimum_s() && c <= maximum_s()); return static_cast(c); } in_t apply_add_u(in_t a, in_t b) { - if (is_floating_point(in_t)) return a + b; + if (is_floating_point()) return a + b; uint64_t c = zero_extend(a) + zero_extend(b); - REQUIRE(c >= minimum_u && c <= maximum_u); + REQUIRE(c >= minimum_u() && c <= maximum_u()); return truncate(c); } @@ -28,7 +28,7 @@ in_t apply_arith_rshift(in_t a, in_t b) { in_t apply_intdiv_s(in_t a, in_t b) { int64_t c = sign_extend(a) / sign_extend(b); - REQUIRE(c >= minimum_s && c <= maximum_s); + REQUIRE(c >= minimum_s() && c <= maximum_s()); return static_cast(c); } @@ -37,7 +37,7 @@ in_t apply_ceil(in_t input) { } in_t apply_clip_s(in_t value, in_t min_val, in_t max_val) { - if (is_floating_point(in_t>) { + if (is_floating_point()) { REQUIRE(min_val <= max_val); } else { @@ -79,7 +79,7 @@ in_t apply_logical_rshift(in_t a, in_t b) { } in_t apply_max_s(in_t a, in_t b) { - if (is_floating_point(in_t)) { + if (is_floating_point()) { if (isNaN(a) || isNaN(b)) { return NaN; } @@ -94,7 +94,7 @@ in_t apply_max_u(in_t a, in_t b) { } in_t apply_min_s(in_t a, in_t b) { - if (is_floating_point(in_t)) { + if (is_floating_point()) { if (isNaN(a) || isNaN(b)) { return NaN; } @@ -109,7 +109,7 @@ in_t apply_min_u(in_t a, in_t b) { } in_t apply_mul_s(in_t a, in_t b) { - if (is_floating_point(in_t)) return a * b; + if (is_floating_point()) return a * b; int64_t c = sign_extend(a) * sign_extend(b); return static_cast(c); } @@ -123,15 +123,15 @@ in_t apply_sqrt(in_t input) { } in_t apply_sub_s(in_t a, in_t b) { - if (is_floating_point(in_t)) return a - b; + if (is_floating_point()) return a - b; int64_t c = sign_extend(a) - sign_extend(b); - REQUIRE(c >= minimum_s && c <= maximum_s); + REQUIRE(c >= minimum_s() && c <= maximum_s()); return static_cast(c); } in_t apply_sub_u(in_t a, in_t b) { uint64_t c = zero_extend(a) - zero_extend(b); - REQUIRE(c >= minimum_u && c <= maximum_u); + REQUIRE(c >= minimum_u() && c <= maximum_u()); return truncate(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(input1, shape, index); - if (is_floating_point(in_out_t) && value1 == -0.0) { + if (is_floating_point() && value1 == -0.0) { value1 = 0.0; } if (static_cast(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 max_value = minimum_s(); 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(value1, apply_sub_s(value2, 1)) & 1 != 0)) { result = result + 1; } - result = apply_clip_s(result, minimum_s, maximum_s); + result = apply_clip_s(result, minimum_s(), maximum_s()); tensor_write(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, sign_extend(output_zp)); - acc = apply_clip_s(acc, minimum_s, maximum_s); + acc = apply_clip_s(acc, minimum_s(), maximum_s()); output_val = static_cast(acc); } tensor_write(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 by -1 // which is not representable in two's complement - REQUIRE(static_cast(value1) / static_cast(value2) <= maximum_s); + REQUIRE(static_cast(value1) / static_cast(value2) <= maximum_s()); in_out_t result = apply_intdiv_s(value1, value2); tensor_write(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(value1) * sign_extend(value2); int64_t round = static_cast(1) << (shift - 1); product = (product + round) >> shift; - REQUIRE(product >= minimum_s && product <= maximum_s) + REQUIRE(product >= minimum_s() && product <= maximum_s()) 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(0, value); value = apply_add_s(value, sign_extend(output_zp)); in_out_t result = truncate(apply_clip_s(value, - minimum_s, - maximum_s)); + minimum_s(), + maximum_s())); tensor_write(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 acc = maximum(); for (i = 0; i < shape1[axis]; i++) { index = flatten(left_index, [i], right_index); in_out_t value = tensor_read(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(output_zp); result = apply_add_s(result, extended_out_zp); out_t out = static_cast(apply_clip_u(result, - minimum_u, - maximum_u)); + minimum_u(), + maximum_u())); } else { int32_t extended_out_zp = sign_extend(output_zp); result = apply_add_s(result, extended_out_zp); out_t out = static_cast(apply_clip_s(result, - minimum_s, - maximum_s)); + minimum_s(), + maximum_s())); } tensor_write(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()) ? 1.0 : scale_x_n; + unit_y = (is_floating_point()) ? 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()) { dy = static_cast(ry) / static_cast(scale_y_n); dx = static_cast(rx) / static_cast(scale_x_n); } else { @@ -61,7 +61,7 @@ for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW, 0 <= c < C) { tensor_write(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()) { iy = (dy >= 0.5) ? iy1 : iy0; ix = (dx >= 0.5) ? ix1 : ix0; } else { -- cgit v1.2.1