aboutsummaryrefslogtreecommitdiff
path: root/pseudocode/operators/CAST.tosac
diff options
context:
space:
mode:
authorEric Kunze <eric.kunze@arm.com>2024-01-22 16:54:29 -0800
committerEric Kunze <eric.kunze@arm.com>2024-01-25 13:19:44 -0800
commit608588390a90e6e337a592b62cf811d1ea8ea0fd (patch)
treece73d71540cf6e58fb94b6a12b90d5c8c04cdd4c /pseudocode/operators/CAST.tosac
parent0808d63e4db076fbbd02e806272ae4ccae6ed72c (diff)
downloadspecification-608588390a90e6e337a592b62cf811d1ea8ea0fd.tar.gz
Handle CAST from fp-type to narrow integer types
Be explicit that the value is converted to int32 and then clamped to the output type range. Also remove use of apply_clip, replacing with either apply_clip_s or apply_clip_u Signed-off-by: Eric Kunze <eric.kunze@arm.com> Change-Id: I0efc7f4d653c1bef13c9989cfe2647208dad9617
Diffstat (limited to 'pseudocode/operators/CAST.tosac')
-rw-r--r--pseudocode/operators/CAST.tosac4
1 files changed, 2 insertions, 2 deletions
diff --git a/pseudocode/operators/CAST.tosac b/pseudocode/operators/CAST.tosac
index 8d816ca..fac73e3 100644
--- a/pseudocode/operators/CAST.tosac
+++ b/pseudocode/operators/CAST.tosac
@@ -17,11 +17,11 @@ for_each(index in shape) {
} else if (out_t == fp16_t || out_t == bf16_t || out_t == fp32_t) {
out = round_to_nearest_float(in);
} else if (in_t == fp16_t || in_t == bf16_t || in_t == fp32_t) {
- out = apply_clip<out_t>(round_to_nearest_int(in), minimum<out_t>, maximum<out_t>);
+ out = truncate<out_t>(apply_clip_s<i32_t>(round_to_nearest_int(in), minimum<out_t>, maximum<out_t>));
} else if (sizeof(out_t) >= sizeof(in_t)) {
out = sign_extend<out_t>(in);
} else {
- out = truncate(in);
+ out = truncate<out_t>(in);
}
tensor_write<out_t>(output, shape, index, out);
}