-
Notifications
You must be signed in to change notification settings - Fork 741
Using generic implementation for 16-bit activations and 8-bit weights for matmul in backends #16008
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |||||||
| #include <executorch/backends/cadence/hifi/operators/operators.h> | ||||||||
| #include <executorch/runtime/kernel/kernel_includes.h> | ||||||||
| #include <xa_nnlib_kernels_api.h> | ||||||||
| #include <on_device_ai/Assistant/Jarvis/min_runtime/operators/generic/op_quantized_linear.h> | ||||||||
| #include <xtensa/tie/xt_datacache.h> | ||||||||
| #include <algorithm> | ||||||||
| #include <cmath> | ||||||||
|
|
@@ -218,7 +219,24 @@ void quantized_linear_out( | |||||||
| int64_t out_zero_point, | ||||||||
| __ET_UNUSED const optional<Tensor>& offset, | ||||||||
| Tensor& out) { | ||||||||
| if (out.scalar_type() == executorch::aten::ScalarType::Byte) { | ||||||||
|
|
||||||||
| if (out.scalar_type() == ::executorch::aten::ScalarType::Short && | ||||||||
| in.scalar_type() == ::executorch::aten::ScalarType::Short && | ||||||||
| weight.scalar_type() == ::executorch::aten::ScalarType::Char) { | ||||||||
| ::impl::generic::native::quantized_linear_out( | ||||||||
| ctx, | ||||||||
| in, | ||||||||
| weight, | ||||||||
| bias, | ||||||||
| in_zero_point, | ||||||||
| weight_zero_point, | ||||||||
| out_multiplier, | ||||||||
| out_shift, | ||||||||
| out_zero_point, | ||||||||
| offset, | ||||||||
| out); | ||||||||
| } | ||||||||
| else if (out.scalar_type() == executorch::aten::ScalarType::Byte) { | ||||||||
|
Comment on lines
+238
to
+239
|
||||||||
| } | |
| else if (out.scalar_type() == executorch::aten::ScalarType::Byte) { | |
| } else if (out.scalar_type() == executorch::aten::ScalarType::Byte) { |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after closing brace on line 296. The 'else' should be on the same line as the closing brace of the preceding if block, or there should be consistent formatting with other similar conditionals in the file.
| } | |
| else if (out.scalar_type() == executorch::aten::ScalarType::Byte) { | |
| } else if (out.scalar_type() == executorch::aten::ScalarType::Byte) { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "executorch/runtime/core/exec_aten/exec_aten.h" | ||
| #include "executorch/runtime/kernel/kernel_runtime_context.h" | ||
|
|
||
| namespace impl { | ||
| namespace HiFi { | ||
| namespace native { | ||
|
|
||
| ::executorch::aten::Tensor& quantized_matmul_out( | ||
| ::executorch::runtime::KernelRuntimeContext& ctx, | ||
| const ::executorch::aten::Tensor& X, | ||
| int64_t X_zero_point, | ||
| const ::executorch::aten::Tensor& Y, | ||
| int64_t Y_zero_point, | ||
| const ::executorch::aten::optional<::executorch::aten::Tensor>& bias, | ||
| int64_t out_multiplier, | ||
| int64_t out_shift, | ||
| int64_t out_zero_point, | ||
| bool transposed, | ||
| ::executorch::aten::Tensor& out); | ||
|
|
||
| } // namespace native | ||
| } // namespace HiFi | ||
| } // namespace impl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable declaration for 'optimized' appears after the early return, but it was previously at the beginning of the function. This creates inconsistent code structure and the variable is now unreachable when the W8A16 path is taken. Consider moving this declaration back before the W8A16 conditional check for consistency with the original code structure.