diff --git a/backends/cadence/aot/functions_hifi.yaml b/backends/cadence/aot/functions_hifi.yaml index d79ac92e285..7a98d704d87 100644 --- a/backends/cadence/aot/functions_hifi.yaml +++ b/backends/cadence/aot/functions_hifi.yaml @@ -204,11 +204,21 @@ - arg_meta: null kernel_name: cadence::impl::HiFi::quantized_linear_out +- func: cadence::quantized_linear.per_tensor_out(Tensor src, Tensor weight, Tensor bias, SymInt src_zero_point, SymInt weight_zero_point, SymInt out_multiplier, SymInt out_shift, SymInt out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!) + kernels: + - arg_meta: null + kernel_name: cadence::impl::HiFi::quantized_linear_per_tensor_out + - func: cadence::quantized_relu.out(Tensor X, Tensor X_zero_point, int out_zero_point, Tensor out_multiplier, Tensor out_shift, *, Tensor(a!) out) -> Tensor(a!) kernels: - arg_meta: null kernel_name: cadence::impl::HiFi::quantized_relu_out +- func: cadence::quantized_relu.per_tensor_out(Tensor X, int X_zero_point, int out_zero_point, int out_multiplier, int out_shift, *, Tensor(a!) out) -> Tensor(a!) + kernels: + - arg_meta: null + kernel_name: cadence::impl::HiFi::quantized_relu_per_tensor_out + - func: cadence::quantized_linear.per_tensor_out(Tensor src, Tensor weight, Tensor bias, SymInt src_zero_point, SymInt weight_zero_point, SymInt out_multiplier, SymInt out_shift, SymInt out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!) kernels: - arg_meta: null diff --git a/backends/cadence/hifi/operators/CMakeLists.txt b/backends/cadence/hifi/operators/CMakeLists.txt index a5a8263bd76..d6820c0700d 100644 --- a/backends/cadence/hifi/operators/CMakeLists.txt +++ b/backends/cadence/hifi/operators/CMakeLists.txt @@ -76,8 +76,8 @@ target_include_directories( # Custom ops that are needed to run the test model. add_library( - custom_ops "quantized_linear_out.cpp" "quantized_layer_norm.cpp" - "quantize_per_tensor.cpp" "quantized_relu_out.cpp" "dequantize_per_tensor.cpp" + custom_ops "op_quantized_linear_out.cpp" "op_quantized_layer_norm.cpp" + "op_quantize_per_tensor.cpp" "op_quantized_relu_out.cpp" "op_dequantize_per_tensor.cpp" ) target_include_directories( custom_ops PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR} diff --git a/backends/cadence/hifi/operators/op_clamp.cpp b/backends/cadence/hifi/operators/op_clamp.cpp index 7a77fd8be8c..05c8659cbcb 100644 --- a/backends/cadence/hifi/operators/op_clamp.cpp +++ b/backends/cadence/hifi/operators/op_clamp.cpp @@ -321,6 +321,16 @@ Tensor& clamp_Tensor_out( return out; } + +Tensor& clamp_tensor_out( + RuntimeContext& ctx, + const Tensor& in, + const executorch::aten::optional& min_opt, + const executorch::aten::optional& max_opt, + Tensor& out) { + clamp_Tensor_out(ctx, in, min_opt, max_opt, out); +} + } // namespace native } // namespace HiFi } // namespace impl diff --git a/backends/cadence/hifi/operators/op_mean.cpp b/backends/cadence/hifi/operators/op_mean.cpp index 82fa7502dea..59cf8581583 100644 --- a/backends/cadence/hifi/operators/op_mean.cpp +++ b/backends/cadence/hifi/operators/op_mean.cpp @@ -168,6 +168,16 @@ Tensor& mean_out( return out; } +Tensor& mean_dim_out( + RuntimeContext& ctx, + const Tensor& in, + optional> dim_list, + bool keepdim, + optional dtype, + Tensor& out) { + mean_out(ctx, in, dim_list, keepdim, dtype, out); +} + } // namespace native } // namespace HiFi } // namespace impl diff --git a/backends/cadence/hifi/operators/op_quantized_relu_out.cpp b/backends/cadence/hifi/operators/op_quantized_relu_out.cpp index ce2ee154e85..b8baa946b98 100644 --- a/backends/cadence/hifi/operators/op_quantized_relu_out.cpp +++ b/backends/cadence/hifi/operators/op_quantized_relu_out.cpp @@ -75,6 +75,46 @@ void quantized_relu_per_tensor_out( } } +void quantized_relu_per_tensor_out( + KernelRuntimeContext& ctx, + const Tensor& input, + const Tensor& in_zero_point, + const int64_t out_zero_point, + const Tensor& out_multiplier, + const Tensor& out_shift, + Tensor& output) { + int8_t _in_zero_point = in_zero_point.const_data_ptr()[0]; + int32_t _out_multiplier = out_multiplier.const_data_ptr()[0]; + int32_t _out_shift = out_shift.const_data_ptr()[0]; + + quantized_relu_per_tensor_out( + ctx, + input, + _in_zero_point, + out_zero_point, + _out_multiplier, + _out_shift, + output); +} + +void quantized_relu_out( + KernelRuntimeContext& ctx, + const Tensor& input, + const int64_t in_zero_point, + const int64_t out_zero_point, + const int64_t out_multiplier, + const int64_t out_shift, + Tensor& output) { + quantized_relu_per_tensor_out( + ctx, + input, + in_zero_point, + out_zero_point, + out_multiplier, + out_shift, + output); +} + } // namespace native } // namespace HiFi } // namespace impl diff --git a/backends/cadence/hifi/operators/op_softmax.cpp b/backends/cadence/hifi/operators/op_softmax.cpp index 2ef233c9ff7..852479ed935 100644 --- a/backends/cadence/hifi/operators/op_softmax.cpp +++ b/backends/cadence/hifi/operators/op_softmax.cpp @@ -194,6 +194,15 @@ Tensor& _softmax_out( return out; } +Tensor& softmax_out( + KernelRuntimeContext& ctx, + const Tensor& in, + int64_t dim, + bool half_to_float, + Tensor& out) { + _softmax_out(ctx, in, dim, half_to_float, out); +} + } // namespace native } // namespace HiFi } // namespace impl