Skip to content

Commit

Permalink
fix for bias caching and scales optimization (#47234)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakpiase authored Oct 24, 2022
1 parent 4021258 commit 7aa608a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,16 @@ class FCMKLDNNHandler
? 1.0f
: ctx.Attr<float>("Scale_out");
const size_t weight_scales_num = scale_weights_data.size();
std::vector<float> output_shift_scale(weight_scales_num);

for (size_t i = 0; i < weight_scales_num; i++) {
for (size_t i = 0; i < weight_scales_num; ++i) {
if (scale_weights_data[i] == 0.0)
output_shift_scale[i] = inner_scale;
scale_weights_data[i] = inner_scale;
else
output_shift_scale[i] =
scale_weights_data[i] =
inner_scale / (scale_in_data * scale_weights_data[i]);
}

return make_tuple(output_shift_scale, scale);
return make_tuple(scale_weights_data, scale);
}

// Computing MKL-DNN's scaling mask which determines along which dimension
Expand Down Expand Up @@ -257,6 +256,7 @@ class FCMKLDNNHandler
this->fwd_pd_->bias_desc(),
to_void_cast<float>(bias_data),
attrs);
this->dev_ctx_.SetBlob(bias_key, memory_p);
}
return memory_p;
}
Expand Down

0 comments on commit 7aa608a

Please sign in to comment.