66 * LICENSE file in the root directory of this source tree.
77 */
88
9- #include < executorch/kernels/portable/cpu/util/reduce_util.h>
10- #include < executorch/runtime/kernel/kernel_includes.h>
11- #include < xa_nnlib_kernels_api.h>
129#include < algorithm>
1310#include < cinttypes>
1411#include < cmath>
1512
16- using exec_aten::Scalar;
17- using exec_aten::ScalarType;
18- using exec_aten::Tensor;
19- using torch::executor::Error;
20- using torch::executor::KernelRuntimeContext;
13+ #include < xa_nnlib_kernels_api.h>
14+
15+ #include < executorch/kernels/portable/cpu/util/reduce_util.h>
16+ #include < executorch/runtime/kernel/kernel_includes.h>
17+
18+ using ::executorch::aten::ArrayRef;
19+ using ::executorch::aten::optional;
20+ using ::executorch::aten::ScalarType;
21+ using ::executorch::aten::Tensor;
22+ using ::executorch::runtime::Error;
23+ using ::executorch::runtime::KernelRuntimeContext;
2124
2225/* ScalarType in Executorch do not have support for below data types.
2326 * So, creating a placeholder for these data types. Once, ScalarTypes is
@@ -142,7 +145,7 @@ void quantize_impl(
142145 int * axis,
143146 int quant_min,
144147 int quant_max) {
145- const exec_aten:: ArrayRef<Tensor::SizesType> input_size = input.sizes ();
148+ const ArrayRef<Tensor::SizesType> input_size = input.sizes ();
146149
147150 int kTensorDimensionLimit = 5 ;
148151
@@ -301,8 +304,8 @@ void quantize_impl(
301304 }
302305 }
303306
304- exec_aten:: optional<exec_aten:: ArrayRef<int64_t >> optional_dim_list{
305- exec_aten:: ArrayRef<int64_t >{dims, size_t (input.dim () - 1 )}};
307+ optional<ArrayRef<int64_t >> optional_dim_list{
308+ ArrayRef<int64_t >{dims, size_t (input.dim () - 1 )}};
306309
307310// Actual quantization logic
308311// input, out are the input and output tensors
@@ -487,8 +490,8 @@ void quantize_impl(
487490 }
488491 }
489492
490- exec_aten:: optional<exec_aten:: ArrayRef<int64_t >> optional_dim_list{
491- exec_aten:: ArrayRef<int64_t >{dims, size_t (input.dim () - 1 )}};
493+ optional<ArrayRef<int64_t >> optional_dim_list{
494+ ArrayRef<int64_t >{dims, size_t (input.dim () - 1 )}};
492495
493496// Actual quantization logic
494497// input, out are the input and output tensors
@@ -565,9 +568,9 @@ Tensor& quantize_per_tensor_out(
565568 int64_t quant_max,
566569 ScalarType dtype,
567570 Tensor& out) {
568- torch::executor:: Error err = resize_tensor (out, input.sizes ());
571+ Error err = resize_tensor (out, input.sizes ());
569572 ET_CHECK_MSG (
570- err == torch::executor:: Error::Ok,
573+ err == Error::Ok,
571574 " Failed to resize out Tensor in quantize_per_tensor_out" );
572575
573576 // check_quantize_per_tensor_args(input, quant_min, quant_max, dtype, out);
@@ -600,7 +603,7 @@ Tensor& quantize_per_tensor_tensor_args_out(
600603 // after ET_KERNEL_CHECK is fully implemented and properly allows non fatal
601604 // failures.
602605 if (scale.scalar_type () != ScalarType::Double) {
603- context.fail (torch::executor:: Error::InvalidArgument);
606+ context.fail (Error::InvalidArgument);
604607 return out;
605608 }
606609 ET_CHECK_MSG (
@@ -657,7 +660,7 @@ Tensor& quantize_per_channel_out(
657660 int64_t quant_max,
658661 ScalarType dtype,
659662 Tensor& out) {
660- torch::executor:: Error err = resize_tensor (out, input.sizes ());
663+ Error err = resize_tensor (out, input.sizes ());
661664
662665 // normalize axis
663666 ET_CHECK_MSG (
@@ -671,7 +674,7 @@ Tensor& quantize_per_channel_out(
671674 }
672675
673676 ET_CHECK_MSG (
674- err == torch::executor:: Error::Ok,
677+ err == Error::Ok,
675678 " Failed to resize out Tensor in quantize_per_channel_out" );
676679
677680 ET_CHECK_MSG (
@@ -776,9 +779,9 @@ Tensor& quantize_per_token_out(
776779 input_strides.data (),
777780 executorch::runtime::TensorShapeDynamism::STATIC);
778781 Tensor reshaped_input (&reshaped_input_impl);
779- torch::executor:: Error err = resize_tensor (out, input.sizes ());
782+ Error err = resize_tensor (out, input.sizes ());
780783 ET_CHECK_MSG (
781- err == torch::executor:: Error::Ok,
784+ err == Error::Ok,
782785 " Failed to resize out Tensor in quantize_per_channel_out" );
783786#endif
784787
0 commit comments