aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWon Jeon <won.jeon@arm.com>2023-06-28 22:34:38 +0000
committerTatWai Chong <tatwai.chong@arm.com>2024-01-25 11:28:38 -0800
commit66704d5aac0819ea1755e800806b869d90552ec6 (patch)
treec7d45aaf9c0a5bc366b33185bf4607d99c40446e
parentc5291695f04901e8abbc26dad6cba10e2c7685f8 (diff)
downloadreference_model-66704d5aac0819ea1755e800806b869d90552ec6.tar.gz
Fix logical right shift operator for signed negative integers
Signed-off-by: Won Jeon <won.jeon@arm.com> Change-Id: Id37100ba8bc2ac64b1f54788c6f765fedfab0816
-rw-r--r--reference_model/src/ops/ewise_binary.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/reference_model/src/ops/ewise_binary.cc b/reference_model/src/ops/ewise_binary.cc
index e1713a0..22ace95 100644
--- a/reference_model/src/ops/ewise_binary.cc
+++ b/reference_model/src/ops/ewise_binary.cc
@@ -1,5 +1,5 @@
-// Copyright (c) 2020-2023, ARM Limited.
+// Copyright (c) 2020-2024, ARM Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -348,21 +348,21 @@ int OpLogicalRightShift<Rank, Dtype>::register_fcn()
this->fcn = [this](InEigenType a, InEigenType b) -> OutEigenType {
REQUIRE(b >= 0 && b <= 31, "OpLogicalRightShift: shift value %d is out of valid range [0, 31]",
(int32_t)b);
- return static_cast<OutEigenType>(static_cast<int8_t>(a) >> b);
+ return static_cast<OutEigenType>(static_cast<int8_t>(static_cast<uint8_t>(a) >> b));
};
break;
case TOSA_REF_TYPE_INT16:
this->fcn = [this](InEigenType a, InEigenType b) -> OutEigenType {
REQUIRE(b >= 0 && b <= 31, "OpLogicalRightShift: shift value %d is out of valid range [0, 31]",
(int32_t)b);
- return static_cast<OutEigenType>(static_cast<int16_t>(a) >> b);
+ return static_cast<OutEigenType>(static_cast<int16_t>(static_cast<uint16_t>(a) >> b));
};
break;
case TOSA_REF_TYPE_INT32:
this->fcn = [this](InEigenType a, InEigenType b) -> OutEigenType {
REQUIRE(b >= 0 && b <= 31, "OpLogicalRightShift: shift value %d is out of valid range [0, 31]",
(int32_t)b);
- return static_cast<OutEigenType>(static_cast<int32_t>(a) >> b);
+ return static_cast<OutEigenType>(static_cast<int32_t>(static_cast<uint32_t>(a) >> b));
};
break;
default: