From: seongwoo chae Date: Tue, 30 Jan 2024 21:22:50 +0000 (+0900) Subject: Casting to larger dtype before performing arithmetic (#12568) X-Git-Tag: accepted/tizen/unified/20240202.165957~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fbd47a6e4758395b72c32db2bfb093a937f21fd7;p=platform%2Fcore%2Fml%2Fnnfw.git 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 --- 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;