Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
chunseoklee committed Sep 26, 2024
1 parent 7745445 commit 4278639
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
15 changes: 11 additions & 4 deletions onert-micro/onert-micro/include/pal/common/PALGRUCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,17 @@ void calculateGRU(const float *input_data, const float *weight_input_data,
}
for (int i = 0; i < num_elements; ++i)
{
if(second_hidden_part[i] > 19) {second_hidden_part[i] = 1;}
else if(second_hidden_part[i] < -19) {second_hidden_part[i] = -1;}
else {
second_hidden_part[i] = std::tanh(second_hidden_part[i]);
if (second_hidden_part[i] > 19)
{
second_hidden_part[i] = 1;
}
else if (second_hidden_part[i] < -19)
{
second_hidden_part[i] = -1;
}
else
{
second_hidden_part[i] = std::tanh(second_hidden_part[i]);
}
}

Expand Down
10 changes: 8 additions & 2 deletions onert-micro/onert-micro/include/pal/common/PALGRUWeightGrad.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,14 @@ void calculateGRUWeightGrads(
float tanh_grad_value;
{
float tanh = std::tanh(tanh_data[i]);
if(tanh_data[i] > 19) {tanh = 1;}
else if(tanh_data[i] < -19) {tanh = -1;}
if (tanh_data[i] > 19)
{
tanh = 1;
}
else if (tanh_data[i] < -19)
{
tanh = -1;
}

tanh_grad_value = (1 - tanh * tanh) * right_middle_mul;
}
Expand Down

0 comments on commit 4278639

Please sign in to comment.