Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch int8PrepareBias to handle nullptr #82

Merged
merged 2 commits into from
Mar 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/tensors/cpu/wasm_intgemm_fallback.cpp
Original file line number Diff line number Diff line change
@@ -64,11 +64,19 @@ extern "C" void int8PrepareBiasFallback(const int8_t* input_B_prepared,
const float* input_bias,
float* output) {
float unquant_factor = (-1) * ((127.0f / scale_A) * (127.0f / scale_B)) / (127.0f);
intgemm::Int8Shift::PrepareBias(
input_B_prepared,
width,
cols_B,
intgemm::callbacks::UnquantizeAndAddBiasAndWrite(unquant_factor, input_bias, output));
if (input_bias == nullptr) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, stylistic. I prefer if (input_bias), and I have used this style of nullptr checking elsewhere.

intgemm::Int8Shift::PrepareBias(
input_B_prepared,
width,
cols_B,
intgemm::callbacks::UnquantizeAndWrite(unquant_factor, output));
} else {
intgemm::Int8Shift::PrepareBias(
input_B_prepared,
width,
cols_B,
intgemm::callbacks::UnquantizeAndAddBiasAndWrite(unquant_factor, input_bias, output));
}
}

extern "C" void int8MultiplyAndAddBiasFallback(const int8_t* input_A_prepared,