Skip to content

Commit

Permalink
add dynamic quantize gemm benchmark [step 1: minmax qparams compute] (p…
Browse files Browse the repository at this point in the history
…ytorch#2297)

Summary:
Pull Request resolved: pytorch#2297

result in https://fb-my.sharepoint.com/:x:/g/personal/jiyuanz_meta_com/Ec94q-KgmslMtQ7nIYT4240BZUyWiK-iQvP1cBgzfgEDWg?e=G62cgs

Reviewed By: jspark1105

Differential Revision: D50590364

fbshipit-source-id: 0214a07fbb7bc1dd237f6af220eb863e71ec4472
  • Loading branch information
Jiyuan Zhang authored and facebook-github-bot committed Feb 7, 2024
1 parent e80d507 commit 3687061
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions fbgemm_gpu/src/qlinear_channelwise/qlinear_channelwise_mtia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ static at::Tensor qlinear_quant(
return x;
}

static at::Tensor qlinear_qparams(
at::Tensor x,
at::Tensor weight,
at::Tensor bias,
at::Tensor input_scale,
at::Tensor weight_scale,
at::Tensor weight_zero_point,
at::Tensor relu) {
assert(x.options().dtype() == at::kHalf);
assert(weight.options().dtype() == at::kQInt8);
assert(bias.options().dtype() == at::kFloat);
assert(input_scale.options().dtype() == at::kFloat);
assert(weight_scale.options().dtype() == at::kFloat);
assert(weight_zero_point.options().dtype() == at::kQUInt8);
return x;
}

TORCH_LIBRARY_FRAGMENT(fbgemm, m) {
m.def(
"qlinear_channelwise(Tensor x, Tensor weight, Tensor "
Expand All @@ -58,4 +75,13 @@ TORCH_LIBRARY_FRAGMENT(fbgemm, m) {
m.impl(
"qlinear_quant",
torch::dispatch(c10::DispatchKey::CPU, TORCH_FN(qlinear_quant)));

m.def(
"qlinear_qparams(Tensor x, Tensor weight, Tensor "
"bias, Tensor input_scale, Tensor weight_scale, Tensor "
"weight_zero_point, Tensor relu) -> Tensor");

m.impl(
"qlinear_qparams",
torch::dispatch(c10::DispatchKey::CPU, TORCH_FN(qlinear_qparams)));
}

0 comments on commit 3687061

Please sign in to comment.