Skip to content

Add UInt16 support to Cadence kernels #6893

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

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion backends/cadence/hifi/operators/dequantize_per_tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ void dequantize_per_tensor_out(
} else if (input.scalar_type() == ScalarType::Short) {
const int16_t* input_data = input.const_data_ptr<int16_t>();
dequantize<int16_t>(out_data, input_data, scale, zero_point, numel);
} else if (input.scalar_type() == ScalarType::Bits16) {
} else if (
input.scalar_type() == ScalarType::Bits16 ||
input.scalar_type() == ScalarType::UInt16) {
const uint16_t* input_data = input.const_data_ptr<uint16_t>();
dequantize<uint16_t>(out_data, input_data, scale, zero_point, numel);
} else if (input.scalar_type() == ScalarType::Int) {
Expand Down
4 changes: 3 additions & 1 deletion backends/cadence/hifi/operators/quantize_per_tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ void quantize_per_tensor_out(
int16_t* out_data = out.mutable_data_ptr<int16_t>();
cadence::impl::HiFi::kernels::quantize<int16_t>(
out_data, input_data, 1. / scale, zero_point, numel);
} else if (out.scalar_type() == ScalarType::Bits16) {
} else if (
out.scalar_type() == ScalarType::Bits16 ||
out.scalar_type() == ScalarType::UInt16) {
uint16_t* out_data = out.mutable_data_ptr<uint16_t>();
cadence::impl::HiFi::kernels::quantize<uint16_t>(
out_data, input_data, 1. / scale, zero_point, numel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ void dequantize_per_tensor_out(
const int8_t* input_data = input.const_data_ptr<int8_t>();
impl::reference::kernels::dequantize<int8_t>(
out_data, input_data, scale, zero_point, numel);
} else if (input.scalar_type() == ScalarType::Bits16) {
} else if (
input.scalar_type() == ScalarType::Bits16 ||
input.scalar_type() == ScalarType::UInt16) {
const uint16_t* input_data = input.const_data_ptr<uint16_t>();
impl::reference::kernels::dequantize<uint16_t>(
out_data, input_data, scale, zero_point, numel);
Expand Down
4 changes: 3 additions & 1 deletion backends/cadence/reference/operators/quantize_per_tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ void quantize_per_tensor_out(
int8_t* out_data = out.mutable_data_ptr<int8_t>();
impl::reference::kernels::quantize<int8_t>(
out_data, input_data, 1. / scale, zero_point, numel);
} else if (out.scalar_type() == ScalarType::Bits16) {
} else if (
out.scalar_type() == ScalarType::Bits16 ||
out.scalar_type() == ScalarType::UInt16) {
uint16_t* out_data = out.mutable_data_ptr<uint16_t>();
impl::reference::kernels::quantize<uint16_t>(
out_data, input_data, 1. / scale, zero_point, numel);
Expand Down
Loading