From fbd47a6e4758395b72c32db2bfb093a937f21fd7 Mon Sep 17 00:00:00 2001 From: seongwoo chae Date: Wed, 31 Jan 2024 06:22:50 +0900 Subject: [PATCH] Casting to larger dtype before performing arithmetic (#12568) This commit casts to larger dtype before performing arithmetic. ONE-DCO-1.0-Signed-off-by: seongwoo --- compiler/luci/pass/src/helpers/SparsityFormatConverter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/luci/pass/src/helpers/SparsityFormatConverter.cpp b/compiler/luci/pass/src/helpers/SparsityFormatConverter.cpp index 72b7d60..c15df2a 100644 --- a/compiler/luci/pass/src/helpers/SparsityFormatConverter.cpp +++ b/compiler/luci/pass/src/helpers/SparsityFormatConverter.cpp @@ -38,7 +38,9 @@ uint64_t GetFlattenedIndex(const std::vector &indices, const std::vector= 0; i--) { - index += indices[i] * sub_elements; + assert(indices[i] >= 0); + assert(sub_elements >= 0); + index += static_cast(indices[i]) * static_cast(sub_elements); sub_elements *= shape[i]; } return index; -- 2.7.4