aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tensorflow/compiler/xla/service/hlo_evaluator.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_evaluator.cc b/tensorflow/compiler/xla/service/hlo_evaluator.cc
index eb6e9feb7c..8016b38d15 100644
--- a/tensorflow/compiler/xla/service/hlo_evaluator.cc
+++ b/tensorflow/compiler/xla/service/hlo_evaluator.cc
@@ -794,6 +794,10 @@ class HloEvaluator::TypedVisitor : public DfsHloVisitorWithDefault {
TF_ASSIGN_OR_RETURN(
parent_->evaluated_[shr],
ElementWiseBinaryOp(shr, [](NativeT lhs_elem, NativeT rhs_elem) {
+ // If shift amount is greater than the number of bits, then return 0.
+ if (rhs_elem >= sizeof(UnsignedT) * CHAR_BIT) {
+ return static_cast<NativeT>(0);
+ }
return static_cast<NativeT>(static_cast<UnsignedT>(lhs_elem) >>
rhs_elem);
}));