From 2aa2552bc4e2bec84c7b6b3718b5a9355bc4c2b0 Mon Sep 17 00:00:00 2001 From: Kevin Petit Date: Thu, 8 Feb 2024 11:04:01 +0000 Subject: pseudocode: a few more simple syntax fixes - Use function call syntax for static_cast and sizeof - Replace undefined in_u_t with in_t - Add missing semicolon Change-Id: If6147ae93b371230cbebdf45a55490bf462a8219 Signed-off-by: Kevin Petit --- pseudocode/library/arithmetic_helpers.tosac | 4 ++-- pseudocode/operators/CAST.tosac | 4 ++-- pseudocode/operators/DEPTHWISE_CONV2D.tosac | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pseudocode/library/arithmetic_helpers.tosac b/pseudocode/library/arithmetic_helpers.tosac index d2a4c46..18d5c64 100644 --- a/pseudocode/library/arithmetic_helpers.tosac +++ b/pseudocode/library/arithmetic_helpers.tosac @@ -17,7 +17,7 @@ in_t apply_add_s(in_t a, in_t b) { in_t apply_add_u(in_t a, in_t 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); } @@ -130,7 +130,7 @@ in_t apply_sub_s(in_t a, in_t b) { 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/CAST.tosac b/pseudocode/operators/CAST.tosac index 4e2dca3..b8fdea9 100644 --- a/pseudocode/operators/CAST.tosac +++ b/pseudocode/operators/CAST.tosac @@ -28,11 +28,11 @@ for_each(index in shape) { out = (in) ? 1 : 0; } else if (is_floating_point()) { out = truncate(apply_clip_s(round_to_nearest_int(in), minimum_s(), maximum_s())); - } else if (sizeof(out_t) >= sizeof(in_t)) { + } else if (sizeof() >= sizeof()) { out = sign_extend(in); } else { out = truncate(in); } } - tensor_write(output, shape, index, out) + tensor_write(output, shape, index, out); } diff --git a/pseudocode/operators/DEPTHWISE_CONV2D.tosac b/pseudocode/operators/DEPTHWISE_CONV2D.tosac index 6cbcc6a..a473375 100644 --- a/pseudocode/operators/DEPTHWISE_CONV2D.tosac +++ b/pseudocode/operators/DEPTHWISE_CONV2D.tosac @@ -30,8 +30,8 @@ for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW, 0 <= c < C, 0 <= m < M) { out_t weight = static_cast(tensor_read(weight, [KH,KW,C,M], [ky,kx,c,m])); - value = apply_sub_s(value, static_castinput_zp); - weight = apply_sub_s(weight, static_castweight_zp); + value = apply_sub_s(value, static_cast(input_zp)); + weight = apply_sub_s(weight, static_cast(weight_zp)); acc = apply_add_s(acc, apply_mul_s(value, weight)); } } -- cgit v1.2.1