Skip to content

Commit 39aa25c

Browse files
committed
portable: Add const to local vars to suppress CPPCHECK warning
CPPCHECK flagged apply_unary_map_reduce_fn<CTYPE, ACC> with a constStatement warning. This is a false positive — the code compiles correctly and the result is assigned to a variable used in subsequent computation. Adding const to the declarations suppresses the warning. Signed-off-by: Youngsik Yang <vacu9708@gmail.com>
1 parent 574bfca commit 39aa25c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

kernels/portable/cpu/op_log_softmax.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Tensor& log_softmax_out(
7070
size,
7171
stride);
7272

73-
ACC temp_sum = apply_unary_map_reduce_fn<CTYPE, ACC>(
73+
const ACC exp_sum = apply_unary_map_reduce_fn<CTYPE, ACC>(
7474
[max_in](const CTYPE val_in) {
7575
return std::exp(
7676
static_cast<ACC>(val_in) - static_cast<ACC>(max_in));
@@ -81,13 +81,13 @@ Tensor& log_softmax_out(
8181
in_data + base,
8282
size,
8383
stride);
84-
temp_sum = std::log(temp_sum);
84+
const ACC log_sum = std::log(exp_sum);
8585

8686
apply_unary_map_fn(
87-
[max_in, temp_sum](const CTYPE val_in) {
87+
[max_in, log_sum](const CTYPE val_in) {
8888
return static_cast<CTYPE>(
8989
static_cast<ACC>(val_in) - static_cast<ACC>(max_in) -
90-
temp_sum);
90+
log_sum);
9191
},
9292
in_data + base,
9393
out_data + base,

0 commit comments

Comments
 (0)