From 8c6e5ff2527566785548543425c8e8220882700e Mon Sep 17 00:00:00 2001 From: shewu Date: Tue, 25 Nov 2025 10:11:44 +0800 Subject: [PATCH] Qualcomm AI Engine Direct - Merge the two pybind libraries into a single library Summary: - Prevent dynamic_cast failures caused by separate typeinfo in each library. --- backends/qualcomm/CMakeLists.txt | 17 +- backends/qualcomm/aot/python/CMakeLists.txt | 6 - .../aot/python/PyQnnManagerAdaptor.cpp | 502 +++++++++++++++++ .../qualcomm/aot/python/PyQnnManagerAdaptor.h | 169 +++++- .../aot/python/PyQnnWrapperAdaptor.cpp | 524 ------------------ .../qualcomm/aot/python/PyQnnWrapperAdaptor.h | 187 ------- backends/qualcomm/aot/python/targets.bzl | 32 -- backends/qualcomm/builders/README.md | 20 +- backends/qualcomm/builders/node_visitor.py | 98 ++-- backends/qualcomm/builders/op_abs.py | 12 +- .../builders/op_adaptive_avg_pool2d.py | 18 +- .../builders/op_adaptive_max_pool2d.py | 20 +- backends/qualcomm/builders/op_add.py | 12 +- backends/qualcomm/builders/op_amax.py | 16 +- backends/qualcomm/builders/op_amin.py | 16 +- backends/qualcomm/builders/op_and.py | 12 +- backends/qualcomm/builders/op_arange.py | 8 +- backends/qualcomm/builders/op_argmax.py | 16 +- backends/qualcomm/builders/op_argmin.py | 16 +- backends/qualcomm/builders/op_asin.py | 12 +- backends/qualcomm/builders/op_atan.py | 12 +- backends/qualcomm/builders/op_avg_pool2d.py | 22 +- backends/qualcomm/builders/op_avg_pool3d.py | 42 +- backends/qualcomm/builders/op_batch_norm.py | 16 +- backends/qualcomm/builders/op_binary.py | 14 +- backends/qualcomm/builders/op_bmm.py | 12 +- backends/qualcomm/builders/op_cat.py | 14 +- backends/qualcomm/builders/op_ceil.py | 12 +- backends/qualcomm/builders/op_clamp.py | 16 +- backends/qualcomm/builders/op_conv.py | 28 +- backends/qualcomm/builders/op_copy.py | 12 +- backends/qualcomm/builders/op_cos.py | 12 +- backends/qualcomm/builders/op_cum_sum.py | 18 +- backends/qualcomm/builders/op_custom_op.py | 12 +- .../qualcomm/builders/op_depth_to_space.py | 16 +- backends/qualcomm/builders/op_dequantize.py | 12 +- backends/qualcomm/builders/op_div.py | 12 +- backends/qualcomm/builders/op_elu.py | 14 +- backends/qualcomm/builders/op_embedding.py | 16 +- backends/qualcomm/builders/op_eq.py | 12 +- backends/qualcomm/builders/op_exp.py | 12 +- backends/qualcomm/builders/op_expand.py | 14 +- backends/qualcomm/builders/op_flip.py | 14 +- backends/qualcomm/builders/op_floor.py | 12 +- backends/qualcomm/builders/op_full.py | 8 +- backends/qualcomm/builders/op_full_like.py | 8 +- backends/qualcomm/builders/op_gather.py | 16 +- backends/qualcomm/builders/op_ge.py | 12 +- backends/qualcomm/builders/op_gelu.py | 12 +- .../qualcomm/builders/op_grid_sampler_2d.py | 28 +- backends/qualcomm/builders/op_group_norm.py | 20 +- backends/qualcomm/builders/op_gt.py | 12 +- backends/qualcomm/builders/op_hardsigmoid.py | 18 +- backends/qualcomm/builders/op_hardswish.py | 12 +- backends/qualcomm/builders/op_hardtanh.py | 16 +- backends/qualcomm/builders/op_index.py | 16 +- backends/qualcomm/builders/op_index_put.py | 68 +-- backends/qualcomm/builders/op_index_select.py | 16 +- .../qualcomm/builders/op_instance_norm.py | 16 +- backends/qualcomm/builders/op_layer_norm.py | 20 +- backends/qualcomm/builders/op_le.py | 12 +- backends/qualcomm/builders/op_linear.py | 18 +- backends/qualcomm/builders/op_log.py | 12 +- backends/qualcomm/builders/op_log_softmax.py | 14 +- backends/qualcomm/builders/op_logical_not.py | 12 +- backends/qualcomm/builders/op_lt.py | 12 +- backends/qualcomm/builders/op_matmul.py | 12 +- backends/qualcomm/builders/op_max.py | 12 +- backends/qualcomm/builders/op_max_dim.py | 16 +- backends/qualcomm/builders/op_max_pool2d.py | 20 +- backends/qualcomm/builders/op_mean_dim.py | 16 +- backends/qualcomm/builders/op_min.py | 12 +- backends/qualcomm/builders/op_min_dim.py | 16 +- backends/qualcomm/builders/op_mul.py | 12 +- backends/qualcomm/builders/op_ne.py | 12 +- backends/qualcomm/builders/op_neg.py | 12 +- backends/qualcomm/builders/op_or.py | 12 +- backends/qualcomm/builders/op_pad.py | 16 +- backends/qualcomm/builders/op_pow.py | 14 +- backends/qualcomm/builders/op_prelu.py | 14 +- backends/qualcomm/builders/op_quantize.py | 12 +- backends/qualcomm/builders/op_relu.py | 12 +- backends/qualcomm/builders/op_repeat.py | 14 +- backends/qualcomm/builders/op_reshape.py | 12 +- backends/qualcomm/builders/op_resize.py | 20 +- backends/qualcomm/builders/op_rms_norm.py | 20 +- backends/qualcomm/builders/op_round.py | 12 +- backends/qualcomm/builders/op_rsqrt.py | 12 +- .../qualcomm/builders/op_scalar_tensor.py | 8 +- backends/qualcomm/builders/op_select_copy.py | 16 +- backends/qualcomm/builders/op_sigmoid.py | 12 +- backends/qualcomm/builders/op_sign.py | 12 +- backends/qualcomm/builders/op_sin.py | 12 +- backends/qualcomm/builders/op_skip_ops.py | 8 +- backends/qualcomm/builders/op_slice_copy.py | 14 +- .../qualcomm/builders/op_slice_scatter.py | 16 +- backends/qualcomm/builders/op_softmax.py | 14 +- .../qualcomm/builders/op_space_to_depth.py | 16 +- .../qualcomm/builders/op_split_with_sizes.py | 16 +- backends/qualcomm/builders/op_sqrt.py | 12 +- backends/qualcomm/builders/op_squeeze.py | 12 +- backends/qualcomm/builders/op_stack.py | 14 +- backends/qualcomm/builders/op_sub.py | 12 +- backends/qualcomm/builders/op_sum_int_list.py | 16 +- backends/qualcomm/builders/op_tanh.py | 12 +- backends/qualcomm/builders/op_to.py | 24 +- backends/qualcomm/builders/op_topk.py | 18 +- backends/qualcomm/builders/op_transpose.py | 14 +- backends/qualcomm/builders/op_unbind.py | 14 +- backends/qualcomm/builders/op_unsqueeze.py | 12 +- .../builders/op_upsample_bilinear2d.py | 16 +- .../builders/op_upsample_nearest2d.py | 16 +- backends/qualcomm/builders/op_where.py | 16 +- backends/qualcomm/builders/op_xor.py | 12 +- backends/qualcomm/builders/targets.bzl | 1 - backends/qualcomm/debugger/utils.py | 10 +- setup.py | 7 - 117 files changed, 1530 insertions(+), 1629 deletions(-) delete mode 100644 backends/qualcomm/aot/python/PyQnnWrapperAdaptor.cpp delete mode 100644 backends/qualcomm/aot/python/PyQnnWrapperAdaptor.h diff --git a/backends/qualcomm/CMakeLists.txt b/backends/qualcomm/CMakeLists.txt index cc7957dfdbe..2e53c320e6b 100644 --- a/backends/qualcomm/CMakeLists.txt +++ b/backends/qualcomm/CMakeLists.txt @@ -267,15 +267,11 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") ${CMAKE_CURRENT_BINARY_DIR}/pybind11 ) add_library(PyQnnManagerAdaptor MODULE) - add_library(PyQnnWrapperAdaptor MODULE) # PyQnnManager containing a pybind type triggers the warning because pybind11 # code internally forces hidden visibility. set_target_properties( PyQnnManagerAdaptor PROPERTIES CXX_VISIBILITY_PRESET hidden ) - set_target_properties( - PyQnnWrapperAdaptor PROPERTIES CXX_VISIBILITY_PRESET hidden - ) target_link_libraries( PyQnnManagerAdaptor @@ -287,18 +283,14 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") executorch extension_tensor qnn_backend_options - ) - target_link_libraries( - PyQnnWrapperAdaptor PRIVATE pybind11::module pybind11::lto wrappers - qnn_executorch_logging qnn_executorch_header + wrappers + qnn_executorch_logging ) pybind11_extension(PyQnnManagerAdaptor) - pybind11_extension(PyQnnWrapperAdaptor) if(NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo) # Strip unnecessary sections of the binary pybind11_strip(PyQnnManagerAdaptor) - pybind11_strip(PyQnnWrapperAdaptor) endif() if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -309,9 +301,6 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") target_compile_options( PyQnnManagerAdaptor PUBLIC ${_pybind_compile_options} ) - target_compile_options( - PyQnnWrapperAdaptor PUBLIC ${_pybind_compile_options} - ) endif() add_subdirectory( @@ -320,7 +309,7 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") ) install( - TARGETS PyQnnManagerAdaptor PyQnnWrapperAdaptor + TARGETS PyQnnManagerAdaptor LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/executorch/backends/qualcomm/python RUNTIME diff --git a/backends/qualcomm/aot/python/CMakeLists.txt b/backends/qualcomm/aot/python/CMakeLists.txt index 337cfae1776..f84d7f01d86 100644 --- a/backends/qualcomm/aot/python/CMakeLists.txt +++ b/backends/qualcomm/aot/python/CMakeLists.txt @@ -9,9 +9,3 @@ target_sources( PyQnnManagerAdaptor PUBLIC ${CMAKE_CURRENT_LIST_DIR}/PyQnnManagerAdaptor.cpp ${CMAKE_CURRENT_LIST_DIR}/PyQnnManagerAdaptor.h ) - -# PyQnnWrapperAdaptor -target_sources( - PyQnnWrapperAdaptor PUBLIC ${CMAKE_CURRENT_LIST_DIR}/PyQnnWrapperAdaptor.cpp - ${CMAKE_CURRENT_LIST_DIR}/PyQnnWrapperAdaptor.h -) diff --git a/backends/qualcomm/aot/python/PyQnnManagerAdaptor.cpp b/backends/qualcomm/aot/python/PyQnnManagerAdaptor.cpp index 2511cd96636..1dbca33c04d 100644 --- a/backends/qualcomm/aot/python/PyQnnManagerAdaptor.cpp +++ b/backends/qualcomm/aot/python/PyQnnManagerAdaptor.cpp @@ -6,7 +6,11 @@ * LICENSE file in the root directory of this source tree. */ #include +#include +#include +#include #include +#include #include "QnnSdkBuildId.h" namespace py = pybind11; @@ -15,6 +19,133 @@ namespace backends { namespace qnn { using executorch::runtime::Error; +std::unique_ptr CreateQuantizationParamWrapper( + const Qnn_QuantizationEncoding_t& encoding, + py::dict& quant_info) { + std::unique_ptr quantize_param_wrapper; + if (encoding == QNN_QUANTIZATION_ENCODING_UNDEFINED) { + quantize_param_wrapper = std::make_unique(); + } else if (encoding == QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET) { + int32_t axis = quant_info["axis"].cast(); + std::vector scale_offset = + quant_info["scale_offset"].cast>(); + + quantize_param_wrapper = + std::make_unique( + axis, scale_offset); + } else if (encoding == QNN_QUANTIZATION_ENCODING_BW_AXIS_SCALE_OFFSET) { + uint32_t bitwidth = quant_info["bitwidth"].cast(); + int32_t axis = quant_info["axis"].cast(); + std::vector scale_offset = + quant_info["scale_offset"].cast>(); + uint32_t num_elements = scale_offset.size(); + std::vector scales; + std::vector offsets; + for (const auto& scale_offset : scale_offset) { + scales.push_back(scale_offset.scale); + offsets.push_back(scale_offset.offset); + } + quantize_param_wrapper = + std::make_unique( + bitwidth, axis, num_elements, scales, offsets); + } else if (encoding == QNN_QUANTIZATION_ENCODING_BW_SCALE_OFFSET) { + uint32_t bitwidth = quant_info["bitwidth"].cast(); + float scale = quant_info["scale"].cast(); + int32_t offset = quant_info["offset"].cast(); + quantize_param_wrapper = + std::make_unique( + bitwidth, scale, offset); + } else if (encoding == QNN_QUANTIZATION_ENCODING_SCALE_OFFSET) { + float scale = quant_info["scale"].cast(); + int32_t offset = quant_info["offset"].cast(); + quantize_param_wrapper = + std::make_unique(scale, offset); + } else if (encoding == QNN_QUANTIZATION_ENCODING_BLOCKWISE_EXPANSION) { + int32_t axis = quant_info["axis"].cast(); + std::vector scale_offset = + quant_info["block_scale_offset"].cast>(); + uint32_t num_blocks_per_axis = + quant_info["num_blocks_per_axis"].cast(); + uint32_t block_scale_bitwidth = + quant_info["block_scale_bitwidth"].cast(); + Qnn_BlockwiseExpansionBlockScaleStorageType_t block_storage_type = + quant_info["block_storage_type"] + .cast(); + std::vector buf = + quant_info["block_scales"].cast>(); + quantize_param_wrapper = + std::make_unique( + axis, + scale_offset, + num_blocks_per_axis, + block_scale_bitwidth, + block_storage_type, + buf.data(), + buf.size()); + } else { + QNN_EXECUTORCH_LOG_ERROR( + "Unknown the encoding of quantization: %d", encoding); + } + return quantize_param_wrapper; +} + +std::string GetScalarValue(const Qnn_Scalar_t& scalar) { + switch (scalar.dataType) { + case QNN_DATATYPE_FLOAT_32: + return std::to_string(scalar.floatValue); + case QNN_DATATYPE_FLOAT_64: + return std::to_string(scalar.doubleValue); + case QNN_DATATYPE_UINT_64: + return std::to_string(scalar.uint64Value); + case QNN_DATATYPE_INT_64: + return std::to_string(scalar.int64Value); + case QNN_DATATYPE_UINT_32: + return std::to_string(scalar.uint32Value); + case QNN_DATATYPE_INT_32: + return std::to_string(scalar.int32Value); + case QNN_DATATYPE_UINT_16: + return std::to_string(scalar.uint16Value); + case QNN_DATATYPE_INT_16: + return std::to_string(scalar.int16Value); + case QNN_DATATYPE_UINT_8: + return std::to_string(scalar.uint8Value); + case QNN_DATATYPE_INT_8: + return std::to_string(scalar.int8Value); + case QNN_DATATYPE_BOOL_8: + return std::to_string(static_cast(scalar.bool8Value)); + case QNN_DATATYPE_STRING: + return std::string(scalar.stringValue); + default: + return "QNN_DATATYPE_UNDEFINED"; + } +} + +std::shared_ptr CreateTensorWrapper( + const std::string& tensor_name, + Qnn_TensorType_t tensor_type, + Qnn_DataType_t data_type, + const Qnn_QuantizationEncoding_t& encoding, + py::dict& quant_info, + std::uint32_t rank, + const std::vector& dims, + const std::vector& dynamic_dims, + py::array& data, + bool copy_data) { + std::unique_ptr quantize_param_wrapper = + CreateQuantizationParamWrapper(encoding, quant_info); + + return CreateTensorWrapper( + tensor_name, + tensor_type, + data_type, + std::move(quantize_param_wrapper), + rank, + dims.data(), + dynamic_dims.data(), + 0, + data.size() == 0 ? nullptr : data.data(), + copy_data); +} std::string GetQnnSdkBuildId(std::string library_path) { QnnImplementation qnn_loaded_backend = QnnImplementation(library_path); @@ -35,6 +166,7 @@ std::string GetQnnSdkBuildId(std::string library_path) { PYBIND11_MODULE(PyQnnManagerAdaptor, m) { // TODO: Add related documents for configurations listed below using namespace qnn_delegate; + PYBIND11_NUMPY_DTYPE(PyQnnTensorWrapper::EncodingData, scale, offset); m.def("GetQnnSdkBuildId", &GetQnnSdkBuildId); py::class_(m, "QnnExecuTorchContextBinary") @@ -68,6 +200,376 @@ PYBIND11_MODULE(PyQnnManagerAdaptor, m) { "MakeBinaryInfo", py::overload_cast(&PyQnnManager::MakeBinaryInfo)) .def("StripProtocol", &PyQnnManager::StripProtocol); + + py::enum_(m, "Qnn_TensorType_t") + .value( + "QNN_TENSOR_TYPE_APP_WRITE", + Qnn_TensorType_t::QNN_TENSOR_TYPE_APP_WRITE) + .value( + "QNN_TENSOR_TYPE_APP_READ", + Qnn_TensorType_t::QNN_TENSOR_TYPE_APP_READ) + .value( + "QNN_TENSOR_TYPE_APP_READWRITE", + Qnn_TensorType_t::QNN_TENSOR_TYPE_APP_READWRITE) + .value("QNN_TENSOR_TYPE_NATIVE", Qnn_TensorType_t::QNN_TENSOR_TYPE_NATIVE) + .value("QNN_TENSOR_TYPE_STATIC", Qnn_TensorType_t::QNN_TENSOR_TYPE_STATIC) + .value("QNN_TENSOR_TYPE_NULL", Qnn_TensorType_t::QNN_TENSOR_TYPE_NULL) + .value( + "QNN_TENSOR_TYPE_UNDEFINED", + Qnn_TensorType_t::QNN_TENSOR_TYPE_UNDEFINED) + .export_values(); + + py::enum_(m, "Qnn_DataType_t") + .value("QNN_DATATYPE_INT_8", Qnn_DataType_t::QNN_DATATYPE_INT_8) + .value("QNN_DATATYPE_INT_16", Qnn_DataType_t::QNN_DATATYPE_INT_16) + .value("QNN_DATATYPE_INT_32", Qnn_DataType_t::QNN_DATATYPE_INT_32) + .value("QNN_DATATYPE_INT_64", Qnn_DataType_t::QNN_DATATYPE_INT_64) + .value("QNN_DATATYPE_UINT_8", Qnn_DataType_t::QNN_DATATYPE_UINT_8) + .value("QNN_DATATYPE_UINT_16", Qnn_DataType_t::QNN_DATATYPE_UINT_16) + .value("QNN_DATATYPE_UINT_32", Qnn_DataType_t::QNN_DATATYPE_UINT_32) + .value("QNN_DATATYPE_UINT_64", Qnn_DataType_t::QNN_DATATYPE_UINT_64) + .value("QNN_DATATYPE_FLOAT_16", Qnn_DataType_t::QNN_DATATYPE_FLOAT_16) + .value("QNN_DATATYPE_FLOAT_32", Qnn_DataType_t::QNN_DATATYPE_FLOAT_32) + .value( + "QNN_DATATYPE_SFIXED_POINT_8", + Qnn_DataType_t::QNN_DATATYPE_SFIXED_POINT_8) + .value( + "QNN_DATATYPE_SFIXED_POINT_16", + Qnn_DataType_t::QNN_DATATYPE_SFIXED_POINT_16) + .value( + "QNN_DATATYPE_SFIXED_POINT_32", + Qnn_DataType_t::QNN_DATATYPE_SFIXED_POINT_32) + .value( + "QNN_DATATYPE_UFIXED_POINT_8", + Qnn_DataType_t::QNN_DATATYPE_UFIXED_POINT_8) + .value( + "QNN_DATATYPE_UFIXED_POINT_16", + Qnn_DataType_t::QNN_DATATYPE_UFIXED_POINT_16) + .value( + "QNN_DATATYPE_UFIXED_POINT_32", + Qnn_DataType_t::QNN_DATATYPE_UFIXED_POINT_32) + .value("QNN_DATATYPE_BOOL_8", Qnn_DataType_t::QNN_DATATYPE_BOOL_8) + .value("QNN_DATATYPE_UNDEFINED", Qnn_DataType_t::QNN_DATATYPE_UNDEFINED) + .export_values(); + + py::enum_(m, "Qnn_QuantizationEncoding_t") + .value( + "QNN_QUANTIZATION_ENCODING_SCALE_OFFSET", + Qnn_QuantizationEncoding_t::QNN_QUANTIZATION_ENCODING_SCALE_OFFSET) + .value( + "QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET", + Qnn_QuantizationEncoding_t:: + QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET) + .value( + "QNN_QUANTIZATION_ENCODING_BW_SCALE_OFFSET", + Qnn_QuantizationEncoding_t::QNN_QUANTIZATION_ENCODING_BW_SCALE_OFFSET) + .value( + "QNN_QUANTIZATION_ENCODING_BW_AXIS_SCALE_OFFSET", + Qnn_QuantizationEncoding_t:: + QNN_QUANTIZATION_ENCODING_BW_AXIS_SCALE_OFFSET) + .value( + "QNN_QUANTIZATION_ENCODING_BLOCKWISE_EXPANSION", + Qnn_QuantizationEncoding_t:: + QNN_QUANTIZATION_ENCODING_BLOCKWISE_EXPANSION) + .value( + "QNN_QUANTIZATION_ENCODING_UNDEFINED", + Qnn_QuantizationEncoding_t::QNN_QUANTIZATION_ENCODING_UNDEFINED) + .export_values(); + + py::enum_( + m, "Qnn_BlockwiseExpansionBlockScaleStorageType_t") + .value( + "QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_8", + Qnn_BlockwiseExpansionBlockScaleStorageType_t:: + QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_8) + .value( + "QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_16", + Qnn_BlockwiseExpansionBlockScaleStorageType_t:: + QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_16) + .value( + "QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_UNDEFINED", + Qnn_BlockwiseExpansionBlockScaleStorageType_t:: + QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_UNDEFINED) + .export_values(); + + py::class_>(m, "OpWrapper") + .def(py::init< + const std::string&, + const std::string&, + const std::string&>()) + .def( + "GetInputTensors", + &OpWrapper::GetInputTensors, + "A function which gets input tensors") + .def( + "GetOutputTensors", + &OpWrapper::GetOutputTensors, + "A function which gets output tensors") + .def("GetOpType", &OpWrapper::GetOpType, "A function which gets op type") + .def("GetName", &OpWrapper::GetName, "A function which gets name") + .def( + "GetPackageName", + &OpWrapper::GetPackageName, + "A function which gets package name") + .def( + "GetParams", &OpWrapper::GetRawParams, "A function which gets params") + // lambda function + // python: op_wrapper.GetOpConfig() + .def( + "GetOpConfig", + [](OpWrapper& self) { + auto op_config = self.GetOpConfig(); + py::dict result; + py::list params_list; + py::list input_tensors_list; + py::list output_tensors_list; + result["version"] = op_config.version; + result["name"] = QNN_OP_VER_PTR(op_config)->name; + result["packageName"] = QNN_OP_VER_PTR(op_config)->packageName; + result["typeName"] = QNN_OP_VER_PTR(op_config)->typeName; + result["numOfParams"] = QNN_OP_VER_PTR(op_config)->numOfParams; + for (size_t i = 0; i < QNN_OP_VER_PTR(op_config)->numOfParams; + ++i) { + params_list.append(QNN_OP_VER_PTR(op_config)->params[i]); + } + result["params"] = params_list; + result["numOfInputs"] = QNN_OP_VER_PTR(op_config)->numOfInputs; + for (size_t i = 0; i < QNN_OP_VER_PTR(op_config)->numOfInputs; + ++i) { + input_tensors_list.append( + QNN_OP_VER_PTR(op_config)->inputTensors[i]); + } + result["inputTensors"] = input_tensors_list; + result["numOfOutputs"] = QNN_OP_VER_PTR(op_config)->numOfOutputs; + for (size_t i = 0; i < QNN_OP_VER_PTR(op_config)->numOfOutputs; + ++i) { + output_tensors_list.append( + QNN_OP_VER_PTR(op_config)->outputTensors[i]); + } + result["outputTensors"] = output_tensors_list; + return result; + }, + "Get operator configuration"); + + py::class_>(m, "TensorWrapper") + .def(py::init(py::overload_cast< + const std::string&, + Qnn_TensorType_t, + Qnn_DataType_t, + const Qnn_QuantizationEncoding_t&, + py::dict&, + std::uint32_t, + const std::vector&, + const std::vector&, + py::array&, + bool>(&CreateTensorWrapper))); + + py::class_(m, "QuantizeParamsWrapper"); + + py::class_(m, "Qnn_ScaleOffset_t") + .def(py::init()) + .def_readonly("scale", &Qnn_ScaleOffset_t::scale) + .def_readonly("offset", &Qnn_ScaleOffset_t::offset); + + py::class_>( + m, "PyQnnOpWrapper") + .def(py::init< + const std::string&, + const std::string&, + const std::string&>()) + .def( + "AddInputTensors", + &PyQnnOpWrapper::AddInputTensors, + "A function which add input tensor wrapper into op wrapper", + py::arg("tensors")) + .def( + "AddOutputTensors", + &PyQnnOpWrapper::AddOutputTensors, + "A function which add output tensor wrapper into op wrapper", + py::arg("tensors")) + .def( + "AddTensorParam", + &PyQnnOpWrapper::AddTensorParam, + "A function which add tensor parameter into op wrapper", + py::arg("name"), + py::arg("data_type"), + py::arg("rank"), + py::arg("dims"), + py::arg("data"), + py::arg("copy_data")) + .def( + "AddScalarParam", + &PyQnnOpWrapper::AddScalarParam, + "A function which add scalar parameter into op wrapper", + py::arg("name"), + py::arg("data_type"), + py::arg("attrData")) + .def( + "GetOpWrapper", + &PyQnnOpWrapper::GetOpWrapper, + "A function which get op wrapper"); + + py::class_(m, "Encoding") + .def_readonly("data", &PyQnnTensorWrapper::Encoding::data) + .def_readonly("axis", &PyQnnTensorWrapper::Encoding::axis); + + py::class_>( + m, "PyQnnTensorWrapper") + .def(py::init&>()) + .def("GetDims", &PyQnnTensorWrapper::GetDims) + .def("GetDataType", &PyQnnTensorWrapper::GetDataType) + .def("GetName", &PyQnnTensorWrapper::GetName) + .def("GetEncodings", &PyQnnTensorWrapper::GetEncodings); + + py::class_(m, "Qnn_OpConfig") + .def_readonly("version", &Qnn_OpConfig_t::version) + // getter + // python: op_wrapper.GetOpConfig().v1 + .def_property_readonly( + "v1", [](const Qnn_OpConfig_t& config) -> const Qnn_OpConfigV1_t& { + return config.v1; + }); + + py::enum_(m, "Qnn_OpConfigVersion") + .value("QNN_OPCONFIG_VERSION_1", QNN_OPCONFIG_VERSION_1) + .value("QNN_OPCONFIG_VERSION_UNDEFINED", QNN_OPCONFIG_VERSION_UNDEFINED) + .export_values(); + + py::class_(m, "Qnn_OpConfigV1") + .def_readonly("name", &Qnn_OpConfigV1_t::name) + .def_readonly("packageName", &Qnn_OpConfigV1_t::packageName) + .def_readonly("typeName", &Qnn_OpConfigV1_t::typeName) + .def_readonly("numOfParams", &Qnn_OpConfigV1_t::numOfParams) + .def_readonly("params", &Qnn_OpConfigV1_t::params) + .def_readonly("numOfInputs", &Qnn_OpConfigV1_t::numOfInputs) + .def_readonly("inputTensors", &Qnn_OpConfigV1_t::inputTensors) + .def_readonly("numOfOutputs", &Qnn_OpConfigV1_t::numOfOutputs) + .def_readonly("outputTensors", &Qnn_OpConfigV1_t::outputTensors); + + py::class_(m, "Qnn_Param") + .def_readonly("paramType", &Qnn_Param_t::paramType) + .def_readonly("name", &Qnn_Param_t::name) + .def_property_readonly( + "scalarParam", + [](const Qnn_Param_t& param) -> const Qnn_Scalar_t& { + if (param.paramType == Qnn_ParamType_t::QNN_PARAMTYPE_SCALAR) { + return param.scalarParam; + } + throw std::runtime_error("ParamType is not scalar."); + }) + .def_property_readonly( + "tensorParam", [](const Qnn_Param_t& param) -> const Qnn_Tensor_t& { + if (param.paramType == Qnn_ParamType_t::QNN_PARAMTYPE_TENSOR) { + return param.tensorParam; + } + throw std::runtime_error("ParamType is not tensor."); + }); + + py::enum_(m, "Qnn_ParamType_t") + .value("QNN_PARAMTYPE_SCALAR", Qnn_ParamType_t::QNN_PARAMTYPE_SCALAR) + .value("QNN_PARAMTYPE_TENSOR", Qnn_ParamType_t::QNN_PARAMTYPE_TENSOR) + .value( + "QNN_PARAMTYPE_UNDEFINED", Qnn_ParamType_t::QNN_PARAMTYPE_UNDEFINED) + .export_values(); + + py::class_(m, "Qnn_Scalar_t") + .def_readonly("dataType", &Qnn_Scalar_t::dataType) + .def("value", &GetScalarValue, "Get the value of the scalar as a string"); + + py::class_(m, "Qnn_Tensor_t") + .def_readonly("version", &Qnn_Tensor_t::version) + .def_property_readonly("v2", [](Qnn_Tensor_t& t) -> Qnn_TensorV2_t& { + if (t.version == QNN_TENSOR_VERSION_2) { + return t.v2; + } + throw std::runtime_error("Tensor version is not V2."); + }); + + py::enum_(m, "Qnn_TensorVersion_t") + .value("QNN_TENSOR_VERSION_1", Qnn_TensorVersion_t::QNN_TENSOR_VERSION_1) + .value("QNN_TENSOR_VERSION_2", Qnn_TensorVersion_t::QNN_TENSOR_VERSION_2) + .value( + "QNN_TENSOR_VERSION_UNDEFINED", + Qnn_TensorVersion_t::QNN_TENSOR_VERSION_UNDEFINED) + .export_values(); + + py::class_(m, "Qnn_TensorV2_t") + .def_readonly("id", &Qnn_TensorV2_t::id) + .def_readonly("name", &Qnn_TensorV2_t::name) + .def_readonly("type", &Qnn_TensorV2_t::type) + .def_readonly("dataFormat", &Qnn_TensorV2_t::dataFormat) + .def_readonly("dataType", &Qnn_TensorV2_t::dataType) + .def_readonly("quantizeParams", &Qnn_TensorV2_t::quantizeParams) + .def_readonly("rank", &Qnn_TensorV2_t::rank) + // change dimensions pointer to vector(begin to rank) + .def_property_readonly( + "dimensions", + [](const Qnn_TensorV2_t& t) { + return std::vector(t.dimensions, t.dimensions + t.rank); + }) + .def_property_readonly( + "isDynamicDimensions", + [](const Qnn_TensorV2_t& t) { + return t.dimensions == nullptr + ? std::vector() + : std::vector(t.dimensions, t.dimensions + t.rank); + }) + .def_readonly("memType", &Qnn_TensorV2_t::memType); + + py::enum_(m, "Qnn_TensorMemType_t") + .value( + "QNN_TENSORMEMTYPE_RAW", Qnn_TensorMemType_t::QNN_TENSORMEMTYPE_RAW) + .value( + "QNN_TENSORMEMTYPE_MEMHANDLE", + Qnn_TensorMemType_t::QNN_TENSORMEMTYPE_MEMHANDLE) + .value( + "QNN_TENSORMEMTYPE_UNDEFINED", + Qnn_TensorMemType_t::QNN_TENSORMEMTYPE_UNDEFINED) + .export_values(); + + py::class_(m, "QnnQuantizeParams") + .def_readonly( + "encodingDefinition", &Qnn_QuantizeParams_t::encodingDefinition) + .def_readonly( + "quantizationEncoding", &Qnn_QuantizeParams_t::quantizationEncoding) + .def_property_readonly( + "scaleOffsetEncoding", + [](const Qnn_QuantizeParams_t& qp) { + if (qp.quantizationEncoding == + QNN_QUANTIZATION_ENCODING_SCALE_OFFSET) { + return qp.scaleOffsetEncoding; + } + throw std::runtime_error( + "Invalid quantization encoding type for scaleOffsetEncoding."); + }) + .def_property_readonly( + "axisScaleOffsetEncoding", [](const Qnn_QuantizeParams_t& qp) { + if (qp.quantizationEncoding == + QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET) { + return qp.axisScaleOffsetEncoding; + } + throw std::runtime_error( + "Invalid quantization encoding type for axisScaleOffsetEncoding."); + }); + + py::enum_(m, "QnnDefinition") + .value( + "QNN_DEFINITION_IMPL_GENERATED", + Qnn_Definition_t::QNN_DEFINITION_IMPL_GENERATED) + .value("QNN_DEFINITION_DEFINED", Qnn_Definition_t::QNN_DEFINITION_DEFINED) + .value( + "QNN_DEFINITION_UNDEFINED", + Qnn_Definition_t::QNN_DEFINITION_UNDEFINED) + .export_values(); + + py::class_(m, "QnnAxisScaleOffset") + .def_readonly("axis", &Qnn_AxisScaleOffset_t::axis) + .def_readonly("numScaleOffsets", &Qnn_AxisScaleOffset_t::numScaleOffsets) + .def_property_readonly( + "scaleOffset", [](const Qnn_AxisScaleOffset_t& aso) { + return std::vector( + aso.scaleOffset, aso.scaleOffset + aso.numScaleOffsets); + }); } } // namespace qnn } // namespace backends diff --git a/backends/qualcomm/aot/python/PyQnnManagerAdaptor.h b/backends/qualcomm/aot/python/PyQnnManagerAdaptor.h index c8044e5db0e..7d262f7f09a 100644 --- a/backends/qualcomm/aot/python/PyQnnManagerAdaptor.h +++ b/backends/qualcomm/aot/python/PyQnnManagerAdaptor.h @@ -6,7 +6,8 @@ * LICENSE file in the root directory of this source tree. */ #pragma once -#include +#include +#include #include #include #include @@ -22,6 +23,171 @@ namespace py = pybind11; namespace executorch { namespace backends { namespace qnn { +class PyQnnOpWrapper { + public: + explicit PyQnnOpWrapper( + const std::string& name, + const std::string& package_name, + const std::string& op_type) { + op_wrapper_ = std::make_shared(name, package_name, op_type); + } + void AddInputTensors( + const std::vector>& tensors) { + op_wrapper_->AddInputTensors(tensors); + } + + void AddOutputTensors( + const std::vector>& tensors) { + op_wrapper_->AddOutputTensors(tensors); + } + + void AddTensorParam( + const std::string& name, + Qnn_DataType_t data_type, + std::uint32_t rank, + const std::vector& dims, + py::array& data, + bool copy_data) { + op_wrapper_->AddTensorParam( + name, data_type, rank, dims.data(), data.data(), copy_data); + } + + void AddScalarParam( + const std::string& name, + Qnn_DataType_t data_type, + py::dict& attrData) { + switch (data_type) { + case Qnn_DataType_t::QNN_DATATYPE_INT_32: + op_wrapper_->AddScalarParam( + name, data_type, attrData["data"].cast()); + break; + case Qnn_DataType_t::QNN_DATATYPE_INT_16: + op_wrapper_->AddScalarParam( + name, data_type, attrData["data"].cast()); + break; + case Qnn_DataType_t::QNN_DATATYPE_INT_8: + op_wrapper_->AddScalarParam( + name, data_type, attrData["data"].cast()); + break; + case Qnn_DataType_t::QNN_DATATYPE_UINT_32: + op_wrapper_->AddScalarParam( + name, data_type, attrData["data"].cast()); + break; + case Qnn_DataType_t::QNN_DATATYPE_UINT_16: + op_wrapper_->AddScalarParam( + name, data_type, attrData["data"].cast()); + break; + case Qnn_DataType_t::QNN_DATATYPE_UINT_8: + op_wrapper_->AddScalarParam( + name, data_type, attrData["data"].cast()); + break; + case Qnn_DataType_t::QNN_DATATYPE_FLOAT_32: + case Qnn_DataType_t::QNN_DATATYPE_FLOAT_16: + op_wrapper_->AddScalarParam( + name, data_type, attrData["data"].cast()); + break; + case Qnn_DataType_t::QNN_DATATYPE_BOOL_8: + op_wrapper_->AddScalarParam( + name, data_type, attrData["data"].cast()); + break; + default: + QNN_EXECUTORCH_LOG_ERROR( + "%s has invalid data type: %d", name.c_str(), data_type); + break; + } + } + std::shared_ptr& GetOpWrapper() { + return op_wrapper_; + } + + private: + std::shared_ptr op_wrapper_; +}; + +class PyQnnTensorWrapper { + public: + explicit PyQnnTensorWrapper(const std::shared_ptr& wrapper) { + tensor_wrapper_ = wrapper; + } + struct EncodingData { + float scale; + int32_t offset; + }; + struct Encoding { + py::array_t data; + int32_t axis; + }; + + py::array_t GetDims() { + std::uint32_t* dim = tensor_wrapper_->GetDims(); + size_t shape[1]{tensor_wrapper_->GetRank()}; + size_t stride[1]{sizeof(std::uint32_t)}; + auto ret = py::array_t(shape, stride); + auto view = ret.mutable_unchecked<1>(); + for (int i = 0; i < ret.shape(0); ++i) { + view(i) = dim[i]; + } + return ret; + } + std::string GetName() { + return tensor_wrapper_->GetName(); + } + Qnn_DataType_t GetDataType() { + return tensor_wrapper_->GetDataType(); + } + Encoding GetEncodings() { + auto q_param = tensor_wrapper_->GetQuantizeParams(); + size_t stride[1]{sizeof(EncodingData)}; + + switch (q_param.quantizationEncoding) { + case QNN_QUANTIZATION_ENCODING_SCALE_OFFSET: { + Qnn_ScaleOffset_t data = q_param.scaleOffsetEncoding; + size_t shape[1]{1}; + auto enc_data = py::array_t(shape, stride); + auto view = enc_data.mutable_unchecked<1>(); + view(0) = {data.scale, data.offset}; + return {enc_data, -1}; + } + case QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET: { + Qnn_AxisScaleOffset_t data = q_param.axisScaleOffsetEncoding; + size_t shape[1]{data.numScaleOffsets}; + auto enc_data = py::array_t(shape, stride); + auto view = enc_data.mutable_unchecked<1>(); + for (int i = 0; i < enc_data.shape(0); ++i) { + view(i) = {data.scaleOffset[i].scale, data.scaleOffset[i].offset}; + } + return {enc_data, data.axis}; + } + case QNN_QUANTIZATION_ENCODING_BW_SCALE_OFFSET: { + Qnn_BwScaleOffset_t data = q_param.bwScaleOffsetEncoding; + size_t shape[1]{1}; + auto enc_data = py::array_t(shape, stride); + auto view = enc_data.mutable_unchecked<1>(); + view(0) = {data.scale, data.offset}; + return {enc_data, -1}; + } + case QNN_QUANTIZATION_ENCODING_BW_AXIS_SCALE_OFFSET: { + Qnn_BwAxisScaleOffset_t data = q_param.bwAxisScaleOffsetEncoding; + size_t shape[1]{data.numElements}; + auto enc_data = py::array_t(shape, stride); + auto view = enc_data.mutable_unchecked<1>(); + for (int i = 0; i < enc_data.shape(0); ++i) { + view(i) = {data.scales[i], data.offsets[i]}; + } + return {enc_data, data.axis}; + } + default: + QNN_EXECUTORCH_LOG_WARN( + "%s QNN_QUANTIZATION_ENCODING_UNDEFINED detected", + GetName().c_str()); + break; + } + return {}; + } + + private: + std::shared_ptr tensor_wrapper_; +}; class PyQnnManager { public: // used for AoT compilation @@ -180,6 +346,7 @@ class PyQnnManager { QnnContextCustomProtocol custom_context_custom_buffer_; flatbuffers::FlatBufferBuilder builder_; }; + } // namespace qnn } // namespace backends } // namespace executorch diff --git a/backends/qualcomm/aot/python/PyQnnWrapperAdaptor.cpp b/backends/qualcomm/aot/python/PyQnnWrapperAdaptor.cpp deleted file mode 100644 index 39f1f3ee48f..00000000000 --- a/backends/qualcomm/aot/python/PyQnnWrapperAdaptor.cpp +++ /dev/null @@ -1,524 +0,0 @@ -/* - * Copyright (c) Qualcomm Innovation Center, Inc. - * 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. - */ -#include -#include -#include -#include -#include -#include - -#include - -namespace py = pybind11; -namespace executorch { -namespace backends { -namespace qnn { -std::unique_ptr CreateQuantizationParamWrapper( - const Qnn_QuantizationEncoding_t& encoding, - py::dict& quant_info) { - std::unique_ptr quantize_param_wrapper; - if (encoding == QNN_QUANTIZATION_ENCODING_UNDEFINED) { - quantize_param_wrapper = std::make_unique(); - } else if (encoding == QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET) { - int32_t axis = quant_info["axis"].cast(); - std::vector scale_offset = - quant_info["scale_offset"].cast>(); - - quantize_param_wrapper = - std::make_unique( - axis, scale_offset); - } else if (encoding == QNN_QUANTIZATION_ENCODING_BW_AXIS_SCALE_OFFSET) { - uint32_t bitwidth = quant_info["bitwidth"].cast(); - int32_t axis = quant_info["axis"].cast(); - std::vector scale_offset = - quant_info["scale_offset"].cast>(); - uint32_t num_elements = scale_offset.size(); - std::vector scales; - std::vector offsets; - for (const auto& scale_offset : scale_offset) { - scales.push_back(scale_offset.scale); - offsets.push_back(scale_offset.offset); - } - quantize_param_wrapper = - std::make_unique( - bitwidth, axis, num_elements, scales, offsets); - } else if (encoding == QNN_QUANTIZATION_ENCODING_BW_SCALE_OFFSET) { - uint32_t bitwidth = quant_info["bitwidth"].cast(); - float scale = quant_info["scale"].cast(); - int32_t offset = quant_info["offset"].cast(); - quantize_param_wrapper = - std::make_unique( - bitwidth, scale, offset); - } else if (encoding == QNN_QUANTIZATION_ENCODING_SCALE_OFFSET) { - float scale = quant_info["scale"].cast(); - int32_t offset = quant_info["offset"].cast(); - quantize_param_wrapper = - std::make_unique(scale, offset); - } else if (encoding == QNN_QUANTIZATION_ENCODING_BLOCKWISE_EXPANSION) { - int32_t axis = quant_info["axis"].cast(); - std::vector scale_offset = - quant_info["block_scale_offset"].cast>(); - uint32_t num_blocks_per_axis = - quant_info["num_blocks_per_axis"].cast(); - uint32_t block_scale_bitwidth = - quant_info["block_scale_bitwidth"].cast(); - Qnn_BlockwiseExpansionBlockScaleStorageType_t block_storage_type = - quant_info["block_storage_type"] - .cast(); - std::vector buf = - quant_info["block_scales"].cast>(); - quantize_param_wrapper = - std::make_unique( - axis, - scale_offset, - num_blocks_per_axis, - block_scale_bitwidth, - block_storage_type, - buf.data(), - buf.size()); - } else { - QNN_EXECUTORCH_LOG_ERROR( - "Unknown the encoding of quantization: %d", encoding); - } - return quantize_param_wrapper; -} - -std::string GetScalarValue(const Qnn_Scalar_t& scalar) { - switch (scalar.dataType) { - case QNN_DATATYPE_FLOAT_32: - return std::to_string(scalar.floatValue); - case QNN_DATATYPE_FLOAT_64: - return std::to_string(scalar.doubleValue); - case QNN_DATATYPE_UINT_64: - return std::to_string(scalar.uint64Value); - case QNN_DATATYPE_INT_64: - return std::to_string(scalar.int64Value); - case QNN_DATATYPE_UINT_32: - return std::to_string(scalar.uint32Value); - case QNN_DATATYPE_INT_32: - return std::to_string(scalar.int32Value); - case QNN_DATATYPE_UINT_16: - return std::to_string(scalar.uint16Value); - case QNN_DATATYPE_INT_16: - return std::to_string(scalar.int16Value); - case QNN_DATATYPE_UINT_8: - return std::to_string(scalar.uint8Value); - case QNN_DATATYPE_INT_8: - return std::to_string(scalar.int8Value); - case QNN_DATATYPE_BOOL_8: - return std::to_string(static_cast(scalar.bool8Value)); - case QNN_DATATYPE_STRING: - return std::string(scalar.stringValue); - default: - return "QNN_DATATYPE_UNDEFINED"; - } -} - -std::shared_ptr CreateTensorWrapper( - const std::string& tensor_name, - Qnn_TensorType_t tensor_type, - Qnn_DataType_t data_type, - const Qnn_QuantizationEncoding_t& encoding, - py::dict& quant_info, - std::uint32_t rank, - const std::vector& dims, - const std::vector& dynamic_dims, - py::array& data, - bool copy_data) { - std::unique_ptr quantize_param_wrapper = - CreateQuantizationParamWrapper(encoding, quant_info); - - return CreateTensorWrapper( - tensor_name, - tensor_type, - data_type, - std::move(quantize_param_wrapper), - rank, - dims.data(), - dynamic_dims.data(), - 0, - data.size() == 0 ? nullptr : data.data(), - copy_data); -} - -PYBIND11_MODULE(PyQnnWrapperAdaptor, m) { - PYBIND11_NUMPY_DTYPE(PyQnnTensorWrapper::EncodingData, scale, offset); - - py::enum_(m, "Qnn_TensorType_t") - .value( - "QNN_TENSOR_TYPE_APP_WRITE", - Qnn_TensorType_t::QNN_TENSOR_TYPE_APP_WRITE) - .value( - "QNN_TENSOR_TYPE_APP_READ", - Qnn_TensorType_t::QNN_TENSOR_TYPE_APP_READ) - .value( - "QNN_TENSOR_TYPE_APP_READWRITE", - Qnn_TensorType_t::QNN_TENSOR_TYPE_APP_READWRITE) - .value("QNN_TENSOR_TYPE_NATIVE", Qnn_TensorType_t::QNN_TENSOR_TYPE_NATIVE) - .value("QNN_TENSOR_TYPE_STATIC", Qnn_TensorType_t::QNN_TENSOR_TYPE_STATIC) - .value("QNN_TENSOR_TYPE_NULL", Qnn_TensorType_t::QNN_TENSOR_TYPE_NULL) - .value( - "QNN_TENSOR_TYPE_UNDEFINED", - Qnn_TensorType_t::QNN_TENSOR_TYPE_UNDEFINED) - .export_values(); - - py::enum_(m, "Qnn_DataType_t") - .value("QNN_DATATYPE_INT_8", Qnn_DataType_t::QNN_DATATYPE_INT_8) - .value("QNN_DATATYPE_INT_16", Qnn_DataType_t::QNN_DATATYPE_INT_16) - .value("QNN_DATATYPE_INT_32", Qnn_DataType_t::QNN_DATATYPE_INT_32) - .value("QNN_DATATYPE_INT_64", Qnn_DataType_t::QNN_DATATYPE_INT_64) - .value("QNN_DATATYPE_UINT_8", Qnn_DataType_t::QNN_DATATYPE_UINT_8) - .value("QNN_DATATYPE_UINT_16", Qnn_DataType_t::QNN_DATATYPE_UINT_16) - .value("QNN_DATATYPE_UINT_32", Qnn_DataType_t::QNN_DATATYPE_UINT_32) - .value("QNN_DATATYPE_UINT_64", Qnn_DataType_t::QNN_DATATYPE_UINT_64) - .value("QNN_DATATYPE_FLOAT_16", Qnn_DataType_t::QNN_DATATYPE_FLOAT_16) - .value("QNN_DATATYPE_FLOAT_32", Qnn_DataType_t::QNN_DATATYPE_FLOAT_32) - .value( - "QNN_DATATYPE_SFIXED_POINT_8", - Qnn_DataType_t::QNN_DATATYPE_SFIXED_POINT_8) - .value( - "QNN_DATATYPE_SFIXED_POINT_16", - Qnn_DataType_t::QNN_DATATYPE_SFIXED_POINT_16) - .value( - "QNN_DATATYPE_SFIXED_POINT_32", - Qnn_DataType_t::QNN_DATATYPE_SFIXED_POINT_32) - .value( - "QNN_DATATYPE_UFIXED_POINT_8", - Qnn_DataType_t::QNN_DATATYPE_UFIXED_POINT_8) - .value( - "QNN_DATATYPE_UFIXED_POINT_16", - Qnn_DataType_t::QNN_DATATYPE_UFIXED_POINT_16) - .value( - "QNN_DATATYPE_UFIXED_POINT_32", - Qnn_DataType_t::QNN_DATATYPE_UFIXED_POINT_32) - .value("QNN_DATATYPE_BOOL_8", Qnn_DataType_t::QNN_DATATYPE_BOOL_8) - .value("QNN_DATATYPE_UNDEFINED", Qnn_DataType_t::QNN_DATATYPE_UNDEFINED) - .export_values(); - - py::enum_(m, "Qnn_QuantizationEncoding_t") - .value( - "QNN_QUANTIZATION_ENCODING_SCALE_OFFSET", - Qnn_QuantizationEncoding_t::QNN_QUANTIZATION_ENCODING_SCALE_OFFSET) - .value( - "QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET", - Qnn_QuantizationEncoding_t:: - QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET) - .value( - "QNN_QUANTIZATION_ENCODING_BW_SCALE_OFFSET", - Qnn_QuantizationEncoding_t::QNN_QUANTIZATION_ENCODING_BW_SCALE_OFFSET) - .value( - "QNN_QUANTIZATION_ENCODING_BW_AXIS_SCALE_OFFSET", - Qnn_QuantizationEncoding_t:: - QNN_QUANTIZATION_ENCODING_BW_AXIS_SCALE_OFFSET) - .value( - "QNN_QUANTIZATION_ENCODING_BLOCKWISE_EXPANSION", - Qnn_QuantizationEncoding_t:: - QNN_QUANTIZATION_ENCODING_BLOCKWISE_EXPANSION) - .value( - "QNN_QUANTIZATION_ENCODING_UNDEFINED", - Qnn_QuantizationEncoding_t::QNN_QUANTIZATION_ENCODING_UNDEFINED) - .export_values(); - - py::enum_( - m, "Qnn_BlockwiseExpansionBlockScaleStorageType_t") - .value( - "QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_8", - Qnn_BlockwiseExpansionBlockScaleStorageType_t:: - QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_8) - .value( - "QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_16", - Qnn_BlockwiseExpansionBlockScaleStorageType_t:: - QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_16) - .value( - "QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_UNDEFINED", - Qnn_BlockwiseExpansionBlockScaleStorageType_t:: - QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_UNDEFINED) - .export_values(); - - py::class_>(m, "OpWrapper") - .def(py::init< - const std::string&, - const std::string&, - const std::string&>()) - .def( - "GetInputTensors", - &OpWrapper::GetInputTensors, - "A function which gets input tensors") - .def( - "GetOutputTensors", - &OpWrapper::GetOutputTensors, - "A function which gets output tensors") - .def("GetOpType", &OpWrapper::GetOpType, "A function which gets op type") - .def("GetName", &OpWrapper::GetName, "A function which gets name") - .def( - "GetPackageName", - &OpWrapper::GetPackageName, - "A function which gets package name") - .def( - "GetParams", &OpWrapper::GetRawParams, "A function which gets params") - // lambda function - // python: op_wrapper.GetOpConfig() - .def( - "GetOpConfig", - [](OpWrapper& self) { - auto op_config = self.GetOpConfig(); - py::dict result; - py::list params_list; - py::list input_tensors_list; - py::list output_tensors_list; - result["version"] = op_config.version; - result["name"] = QNN_OP_VER_PTR(op_config)->name; - result["packageName"] = QNN_OP_VER_PTR(op_config)->packageName; - result["typeName"] = QNN_OP_VER_PTR(op_config)->typeName; - result["numOfParams"] = QNN_OP_VER_PTR(op_config)->numOfParams; - for (size_t i = 0; i < QNN_OP_VER_PTR(op_config)->numOfParams; - ++i) { - params_list.append(QNN_OP_VER_PTR(op_config)->params[i]); - } - result["params"] = params_list; - result["numOfInputs"] = QNN_OP_VER_PTR(op_config)->numOfInputs; - for (size_t i = 0; i < QNN_OP_VER_PTR(op_config)->numOfInputs; - ++i) { - input_tensors_list.append( - QNN_OP_VER_PTR(op_config)->inputTensors[i]); - } - result["inputTensors"] = input_tensors_list; - result["numOfOutputs"] = QNN_OP_VER_PTR(op_config)->numOfOutputs; - for (size_t i = 0; i < QNN_OP_VER_PTR(op_config)->numOfOutputs; - ++i) { - output_tensors_list.append( - QNN_OP_VER_PTR(op_config)->outputTensors[i]); - } - result["outputTensors"] = output_tensors_list; - return result; - }, - "Get operator configuration"); - - py::class_>(m, "TensorWrapper") - .def(py::init(py::overload_cast< - const std::string&, - Qnn_TensorType_t, - Qnn_DataType_t, - const Qnn_QuantizationEncoding_t&, - py::dict&, - std::uint32_t, - const std::vector&, - const std::vector&, - py::array&, - bool>(&CreateTensorWrapper))); - - py::class_(m, "QuantizeParamsWrapper"); - - py::class_(m, "Qnn_ScaleOffset_t") - .def(py::init()) - .def_readonly("scale", &Qnn_ScaleOffset_t::scale) - .def_readonly("offset", &Qnn_ScaleOffset_t::offset); - - py::class_>( - m, "PyQnnOpWrapper") - .def(py::init< - const std::string&, - const std::string&, - const std::string&>()) - .def( - "AddInputTensors", - &PyQnnOpWrapper::AddInputTensors, - "A function which add input tensor wrapper into op wrapper", - py::arg("tensors")) - .def( - "AddOutputTensors", - &PyQnnOpWrapper::AddOutputTensors, - "A function which add output tensor wrapper into op wrapper", - py::arg("tensors")) - .def( - "AddTensorParam", - &PyQnnOpWrapper::AddTensorParam, - "A function which add tensor parameter into op wrapper", - py::arg("name"), - py::arg("data_type"), - py::arg("rank"), - py::arg("dims"), - py::arg("data"), - py::arg("copy_data")) - .def( - "AddScalarParam", - &PyQnnOpWrapper::AddScalarParam, - "A function which add scalar parameter into op wrapper", - py::arg("name"), - py::arg("data_type"), - py::arg("attrData")) - .def( - "GetOpWrapper", - &PyQnnOpWrapper::GetOpWrapper, - "A function which get op wrapper"); - - py::class_(m, "Encoding") - .def_readonly("data", &PyQnnTensorWrapper::Encoding::data) - .def_readonly("axis", &PyQnnTensorWrapper::Encoding::axis); - - py::class_>( - m, "PyQnnTensorWrapper") - .def(py::init&>()) - .def("GetDims", &PyQnnTensorWrapper::GetDims) - .def("GetDataType", &PyQnnTensorWrapper::GetDataType) - .def("GetName", &PyQnnTensorWrapper::GetName) - .def("GetEncodings", &PyQnnTensorWrapper::GetEncodings); - - py::class_(m, "Qnn_OpConfig") - .def_readonly("version", &Qnn_OpConfig_t::version) - // getter - // python: op_wrapper.GetOpConfig().v1 - .def_property_readonly( - "v1", [](const Qnn_OpConfig_t& config) -> const Qnn_OpConfigV1_t& { - return config.v1; - }); - - py::enum_(m, "Qnn_OpConfigVersion") - .value("QNN_OPCONFIG_VERSION_1", QNN_OPCONFIG_VERSION_1) - .value("QNN_OPCONFIG_VERSION_UNDEFINED", QNN_OPCONFIG_VERSION_UNDEFINED) - .export_values(); - - py::class_(m, "Qnn_OpConfigV1") - .def_readonly("name", &Qnn_OpConfigV1_t::name) - .def_readonly("packageName", &Qnn_OpConfigV1_t::packageName) - .def_readonly("typeName", &Qnn_OpConfigV1_t::typeName) - .def_readonly("numOfParams", &Qnn_OpConfigV1_t::numOfParams) - .def_readonly("params", &Qnn_OpConfigV1_t::params) - .def_readonly("numOfInputs", &Qnn_OpConfigV1_t::numOfInputs) - .def_readonly("inputTensors", &Qnn_OpConfigV1_t::inputTensors) - .def_readonly("numOfOutputs", &Qnn_OpConfigV1_t::numOfOutputs) - .def_readonly("outputTensors", &Qnn_OpConfigV1_t::outputTensors); - - py::class_(m, "Qnn_Param") - .def_readonly("paramType", &Qnn_Param_t::paramType) - .def_readonly("name", &Qnn_Param_t::name) - .def_property_readonly( - "scalarParam", - [](const Qnn_Param_t& param) -> const Qnn_Scalar_t& { - if (param.paramType == Qnn_ParamType_t::QNN_PARAMTYPE_SCALAR) { - return param.scalarParam; - } - throw std::runtime_error("ParamType is not scalar."); - }) - .def_property_readonly( - "tensorParam", [](const Qnn_Param_t& param) -> const Qnn_Tensor_t& { - if (param.paramType == Qnn_ParamType_t::QNN_PARAMTYPE_TENSOR) { - return param.tensorParam; - } - throw std::runtime_error("ParamType is not tensor."); - }); - - py::enum_(m, "Qnn_ParamType_t") - .value("QNN_PARAMTYPE_SCALAR", Qnn_ParamType_t::QNN_PARAMTYPE_SCALAR) - .value("QNN_PARAMTYPE_TENSOR", Qnn_ParamType_t::QNN_PARAMTYPE_TENSOR) - .value( - "QNN_PARAMTYPE_UNDEFINED", Qnn_ParamType_t::QNN_PARAMTYPE_UNDEFINED) - .export_values(); - - py::class_(m, "Qnn_Scalar_t") - .def_readonly("dataType", &Qnn_Scalar_t::dataType) - .def("value", &GetScalarValue, "Get the value of the scalar as a string"); - - py::class_(m, "Qnn_Tensor_t") - .def_readonly("version", &Qnn_Tensor_t::version) - .def_property_readonly("v2", [](Qnn_Tensor_t& t) -> Qnn_TensorV2_t& { - if (t.version == QNN_TENSOR_VERSION_2) { - return t.v2; - } - throw std::runtime_error("Tensor version is not V2."); - }); - - py::enum_(m, "Qnn_TensorVersion_t") - .value("QNN_TENSOR_VERSION_1", Qnn_TensorVersion_t::QNN_TENSOR_VERSION_1) - .value("QNN_TENSOR_VERSION_2", Qnn_TensorVersion_t::QNN_TENSOR_VERSION_2) - .value( - "QNN_TENSOR_VERSION_UNDEFINED", - Qnn_TensorVersion_t::QNN_TENSOR_VERSION_UNDEFINED) - .export_values(); - - py::class_(m, "Qnn_TensorV2_t") - .def_readonly("id", &Qnn_TensorV2_t::id) - .def_readonly("name", &Qnn_TensorV2_t::name) - .def_readonly("type", &Qnn_TensorV2_t::type) - .def_readonly("dataFormat", &Qnn_TensorV2_t::dataFormat) - .def_readonly("dataType", &Qnn_TensorV2_t::dataType) - .def_readonly("quantizeParams", &Qnn_TensorV2_t::quantizeParams) - .def_readonly("rank", &Qnn_TensorV2_t::rank) - // change dimensions pointer to vector(begin to rank) - .def_property_readonly( - "dimensions", - [](const Qnn_TensorV2_t& t) { - return std::vector(t.dimensions, t.dimensions + t.rank); - }) - .def_property_readonly( - "isDynamicDimensions", - [](const Qnn_TensorV2_t& t) { - return t.dimensions == nullptr - ? std::vector() - : std::vector(t.dimensions, t.dimensions + t.rank); - }) - .def_readonly("memType", &Qnn_TensorV2_t::memType); - - py::enum_(m, "Qnn_TensorMemType_t") - .value( - "QNN_TENSORMEMTYPE_RAW", Qnn_TensorMemType_t::QNN_TENSORMEMTYPE_RAW) - .value( - "QNN_TENSORMEMTYPE_MEMHANDLE", - Qnn_TensorMemType_t::QNN_TENSORMEMTYPE_MEMHANDLE) - .value( - "QNN_TENSORMEMTYPE_UNDEFINED", - Qnn_TensorMemType_t::QNN_TENSORMEMTYPE_UNDEFINED) - .export_values(); - - py::class_(m, "QnnQuantizeParams") - .def_readonly( - "encodingDefinition", &Qnn_QuantizeParams_t::encodingDefinition) - .def_readonly( - "quantizationEncoding", &Qnn_QuantizeParams_t::quantizationEncoding) - .def_property_readonly( - "scaleOffsetEncoding", - [](const Qnn_QuantizeParams_t& qp) { - if (qp.quantizationEncoding == - QNN_QUANTIZATION_ENCODING_SCALE_OFFSET) { - return qp.scaleOffsetEncoding; - } - throw std::runtime_error( - "Invalid quantization encoding type for scaleOffsetEncoding."); - }) - .def_property_readonly( - "axisScaleOffsetEncoding", [](const Qnn_QuantizeParams_t& qp) { - if (qp.quantizationEncoding == - QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET) { - return qp.axisScaleOffsetEncoding; - } - throw std::runtime_error( - "Invalid quantization encoding type for axisScaleOffsetEncoding."); - }); - - py::enum_(m, "QnnDefinition") - .value( - "QNN_DEFINITION_IMPL_GENERATED", - Qnn_Definition_t::QNN_DEFINITION_IMPL_GENERATED) - .value("QNN_DEFINITION_DEFINED", Qnn_Definition_t::QNN_DEFINITION_DEFINED) - .value( - "QNN_DEFINITION_UNDEFINED", - Qnn_Definition_t::QNN_DEFINITION_UNDEFINED) - .export_values(); - - py::class_(m, "QnnAxisScaleOffset") - .def_readonly("axis", &Qnn_AxisScaleOffset_t::axis) - .def_readonly("numScaleOffsets", &Qnn_AxisScaleOffset_t::numScaleOffsets) - .def_property_readonly( - "scaleOffset", [](const Qnn_AxisScaleOffset_t& aso) { - return std::vector( - aso.scaleOffset, aso.scaleOffset + aso.numScaleOffsets); - }); -} -} // namespace qnn -} // namespace backends -} // namespace executorch diff --git a/backends/qualcomm/aot/python/PyQnnWrapperAdaptor.h b/backends/qualcomm/aot/python/PyQnnWrapperAdaptor.h deleted file mode 100644 index 33c0bd63cac..00000000000 --- a/backends/qualcomm/aot/python/PyQnnWrapperAdaptor.h +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) Qualcomm Innovation Center, Inc. - * 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 -#include -#include -#include -#include -#include -namespace py = pybind11; -namespace executorch { -namespace backends { -namespace qnn { -class PyQnnOpWrapper { - public: - explicit PyQnnOpWrapper( - const std::string& name, - const std::string& package_name, - const std::string& op_type) { - op_wrapper_ = std::make_shared(name, package_name, op_type); - } - void AddInputTensors( - const std::vector>& tensors) { - op_wrapper_->AddInputTensors(tensors); - } - - void AddOutputTensors( - const std::vector>& tensors) { - op_wrapper_->AddOutputTensors(tensors); - } - - void AddTensorParam( - const std::string& name, - Qnn_DataType_t data_type, - std::uint32_t rank, - const std::vector& dims, - py::array& data, - bool copy_data) { - op_wrapper_->AddTensorParam( - name, data_type, rank, dims.data(), data.data(), copy_data); - } - - void AddScalarParam( - const std::string& name, - Qnn_DataType_t data_type, - py::dict& attrData) { - switch (data_type) { - case Qnn_DataType_t::QNN_DATATYPE_INT_32: - op_wrapper_->AddScalarParam( - name, data_type, attrData["data"].cast()); - break; - case Qnn_DataType_t::QNN_DATATYPE_INT_16: - op_wrapper_->AddScalarParam( - name, data_type, attrData["data"].cast()); - break; - case Qnn_DataType_t::QNN_DATATYPE_INT_8: - op_wrapper_->AddScalarParam( - name, data_type, attrData["data"].cast()); - break; - case Qnn_DataType_t::QNN_DATATYPE_UINT_32: - op_wrapper_->AddScalarParam( - name, data_type, attrData["data"].cast()); - break; - case Qnn_DataType_t::QNN_DATATYPE_UINT_16: - op_wrapper_->AddScalarParam( - name, data_type, attrData["data"].cast()); - break; - case Qnn_DataType_t::QNN_DATATYPE_UINT_8: - op_wrapper_->AddScalarParam( - name, data_type, attrData["data"].cast()); - break; - case Qnn_DataType_t::QNN_DATATYPE_FLOAT_32: - case Qnn_DataType_t::QNN_DATATYPE_FLOAT_16: - op_wrapper_->AddScalarParam( - name, data_type, attrData["data"].cast()); - break; - case Qnn_DataType_t::QNN_DATATYPE_BOOL_8: - op_wrapper_->AddScalarParam( - name, data_type, attrData["data"].cast()); - break; - default: - QNN_EXECUTORCH_LOG_ERROR( - "%s has invalid data type: %d", name.c_str(), data_type); - break; - } - } - std::shared_ptr& GetOpWrapper() { - return op_wrapper_; - } - - private: - std::shared_ptr op_wrapper_; -}; - -class PyQnnTensorWrapper { - public: - explicit PyQnnTensorWrapper(const std::shared_ptr& wrapper) { - tensor_wrapper_ = wrapper; - } - struct EncodingData { - float scale; - int32_t offset; - }; - struct Encoding { - py::array_t data; - int32_t axis; - }; - - py::array_t GetDims() { - std::uint32_t* dim = tensor_wrapper_->GetDims(); - size_t shape[1]{tensor_wrapper_->GetRank()}; - size_t stride[1]{sizeof(std::uint32_t)}; - auto ret = py::array_t(shape, stride); - auto view = ret.mutable_unchecked<1>(); - for (int i = 0; i < ret.shape(0); ++i) { - view(i) = dim[i]; - } - return ret; - } - std::string GetName() { - return tensor_wrapper_->GetName(); - } - Qnn_DataType_t GetDataType() { - return tensor_wrapper_->GetDataType(); - } - Encoding GetEncodings() { - auto q_param = tensor_wrapper_->GetQuantizeParams(); - size_t stride[1]{sizeof(EncodingData)}; - - switch (q_param.quantizationEncoding) { - case QNN_QUANTIZATION_ENCODING_SCALE_OFFSET: { - Qnn_ScaleOffset_t data = q_param.scaleOffsetEncoding; - size_t shape[1]{1}; - auto enc_data = py::array_t(shape, stride); - auto view = enc_data.mutable_unchecked<1>(); - view(0) = {data.scale, data.offset}; - return {enc_data, -1}; - } - case QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET: { - Qnn_AxisScaleOffset_t data = q_param.axisScaleOffsetEncoding; - size_t shape[1]{data.numScaleOffsets}; - auto enc_data = py::array_t(shape, stride); - auto view = enc_data.mutable_unchecked<1>(); - for (int i = 0; i < enc_data.shape(0); ++i) { - view(i) = {data.scaleOffset[i].scale, data.scaleOffset[i].offset}; - } - return {enc_data, data.axis}; - } - case QNN_QUANTIZATION_ENCODING_BW_SCALE_OFFSET: { - Qnn_BwScaleOffset_t data = q_param.bwScaleOffsetEncoding; - size_t shape[1]{1}; - auto enc_data = py::array_t(shape, stride); - auto view = enc_data.mutable_unchecked<1>(); - view(0) = {data.scale, data.offset}; - return {enc_data, -1}; - } - case QNN_QUANTIZATION_ENCODING_BW_AXIS_SCALE_OFFSET: { - Qnn_BwAxisScaleOffset_t data = q_param.bwAxisScaleOffsetEncoding; - size_t shape[1]{data.numElements}; - auto enc_data = py::array_t(shape, stride); - auto view = enc_data.mutable_unchecked<1>(); - for (int i = 0; i < enc_data.shape(0); ++i) { - view(i) = {data.scales[i], data.offsets[i]}; - } - return {enc_data, data.axis}; - } - default: - QNN_EXECUTORCH_LOG_WARN( - "%s QNN_QUANTIZATION_ENCODING_UNDEFINED detected", - GetName().c_str()); - break; - } - return {}; - } - - private: - std::shared_ptr tensor_wrapper_; -}; -} // namespace qnn -} // namespace backends -} // namespace executorch diff --git a/backends/qualcomm/aot/python/targets.bzl b/backends/qualcomm/aot/python/targets.bzl index 74fbd1da511..0133aa73b93 100644 --- a/backends/qualcomm/aot/python/targets.bzl +++ b/backends/qualcomm/aot/python/targets.bzl @@ -46,38 +46,6 @@ def define_common_targets(): ) - runtime.cxx_python_extension( - name = "PyQnnWrapperAdaptor", - srcs = [ - "PyQnnWrapperAdaptor.cpp", - ], - headers = [ - "PyQnnWrapperAdaptor.h", - ], - base_module = "executorch.backends.qualcomm.python", - preprocessor_flags = [ - "-DEXECUTORCH_PYTHON_MODULE_NAME={}".format(PYTHON_MODULE_NAME), - ], - deps = [ - "//executorch/runtime/core:core", - "//executorch/backends/qualcomm/aot/python:python_lib", - "//executorch/backends/qualcomm/aot/wrappers:wrappers", - "//executorch/backends/qualcomm/runtime:logging", - "//executorch/backends/qualcomm:schema", - "//executorch/backends/qualcomm/runtime:runtime", - "fbsource//third-party/pybind11:pybind11", - "fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()), - "fbsource//third-party/qualcomm/qnn/qnn-{0}:app_sources".format(get_qnn_library_version()), - ], - external_deps = [ - "libtorch_python", - ], - use_static_deps = True, - visibility = [ - "//executorch/backends/qualcomm/...", - ], - ) - runtime.cxx_library( name = "python_lib", srcs = glob([ diff --git a/backends/qualcomm/builders/README.md b/backends/qualcomm/builders/README.md index 2f1c2d54828..5f80fa0adea 100644 --- a/backends/qualcomm/builders/README.md +++ b/backends/qualcomm/builders/README.md @@ -172,7 +172,7 @@ The content should have exact match with literal values mentioned in [Qualcomm A Next, create a new file with name in snake case format (e.g. `op_layer_norm.py`) and import required modules (please check comments for getting the ideas of usage): ```python # pybind interface for invoking QNN APIs -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager # tensors or other numerics will be shipped in numpy format import numpy as np import torch @@ -199,8 +199,8 @@ class LayerNormVisitor(NodeVisitor): def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: ``` It's mandatory to have `target` member in list form, since there would have multiple targets map to the same implementation. e.g. `aten.leaky_relu.default`, `aten.prelu.default` have similar equations but only differ in negative slope.
The `nodes_to_wrappers` is a dictionary maintaining relationship between graph node and its output tensor. `nodes_to_wrappers` acts as an memo for not creating tensor objects to nodes that have already been traversed.
@@ -214,7 +214,7 @@ Now, we can start to fill in function body step by step: input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) ``` @@ -238,7 +238,7 @@ Now, we can start to fill in function body step by step: weight_node, node, weight_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) @@ -248,7 +248,7 @@ Now, we can start to fill in function body step by step: bias_node, node, bias_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) ``` @@ -276,7 +276,7 @@ Now, we can start to fill in function body step by step: node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) ``` @@ -284,7 +284,7 @@ Now, we can start to fill in function body step by step: 5. Generate operator object in QNN graph: ```python - layer_norm_op = PyQnnWrapper.PyQnnOpWrapper( + layer_norm_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpLayerNorm.op_name, @@ -304,12 +304,12 @@ Now, we can start to fill in function body step by step: ```python layer_norm_op.AddScalarParam( OpLayerNorm.param_epsilon, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, {QCOM_DATA: np.float32(epsilon)}, ) layer_norm_op.AddTensorParam( OpLayerNorm.param_axes, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(axis_shape), axis_shape, np.array(axis, dtype=np.uint32), diff --git a/backends/qualcomm/builders/node_visitor.py b/backends/qualcomm/builders/node_visitor.py index f3dadb99129..b2de5288834 100644 --- a/backends/qualcomm/builders/node_visitor.py +++ b/backends/qualcomm/builders/node_visitor.py @@ -7,7 +7,7 @@ import copy from typing import Any, Dict, Tuple -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -48,28 +48,28 @@ QNN_QUANT_TYPE_MAP = { - torch.int8: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_SFIXED_POINT_8, - torch.int16: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_SFIXED_POINT_16, - torch.int32: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_SFIXED_POINT_32, + torch.int8: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_SFIXED_POINT_8, + torch.int16: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_SFIXED_POINT_16, + torch.int32: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_SFIXED_POINT_32, # Note that there is no int64 tensor data type in Qnn. - torch.int64: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UNDEFINED, - torch.uint8: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UFIXED_POINT_8, - torch.uint16: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UFIXED_POINT_16, + torch.int64: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UNDEFINED, + torch.uint8: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UFIXED_POINT_8, + torch.uint16: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UFIXED_POINT_16, } QNN_TENSOR_TYPE_MAP = { - torch.bool: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, - torch.float32: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + torch.bool: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + torch.float32: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, # Note that there is no float64 tensor data type in Qnn. - torch.float64: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, - torch.int8: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_INT_8, - torch.int16: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_INT_16, - torch.int32: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_INT_32, - torch.int64: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_INT_64, - torch.uint8: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_8, - torch.uint16: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_16, - torch.uint32: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, - float: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, - int: PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + torch.float64: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + torch.int8: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_INT_8, + torch.int16: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_INT_16, + torch.int32: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_INT_32, + torch.int64: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_INT_64, + torch.uint8: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_8, + torch.uint16: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_16, + torch.uint32: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + float: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + int: PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, } PER_CHANNEL_ENCODING = { @@ -165,7 +165,7 @@ def make_qnn_per_block_config(self, node: torch.fx.Node, quant_attrs: Dict): quant_scales_dtype = torch.uint8 num_steps = 2**bitwidth_of_scale scale_storage_type = ( - PyQnnWrapper.Qnn_BlockwiseExpansionBlockScaleStorageType_t.QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_8 + PyQnnManager.Qnn_BlockwiseExpansionBlockScaleStorageType_t.QNN_BLOCKWISE_EXPANSION_BITWIDTH_SCALE_STORAGE_8 ) for ch in range(num_channels): @@ -178,7 +178,7 @@ def make_qnn_per_block_config(self, node: torch.fx.Node, quant_attrs: Dict): ).to(quant_scales_dtype) quantized_scales.append(q_scales) # symmetric quantization is required - scale_offset.append(PyQnnWrapper.Qnn_ScaleOffset_t(max_scale, 0)) + scale_offset.append(PyQnnManager.Qnn_ScaleOffset_t(max_scale, 0)) # skip dequantize op, e.g. frozen_param -> dq -> conv2d user_0 = self.get_first_user(node) @@ -202,7 +202,7 @@ def make_qnn_per_block_config(self, node: torch.fx.Node, quant_attrs: Dict): ) quant_config[QCOM_BLOCK_STORAGE_TYPE] = scale_storage_type return ( - PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_BLOCKWISE_EXPANSION, + PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_BLOCKWISE_EXPANSION, quant_config, ) @@ -219,7 +219,7 @@ def make_qnn_per_channel_config(self, node: torch.fx.Node, quant_attrs: Dict): for i in range(len(scales)): # check Qnn_ScaleOffset_t in QNN/include/QnnTypes.h scale_offset.append( - PyQnnWrapper.Qnn_ScaleOffset_t(scales[i], -zero_points[i]) + PyQnnManager.Qnn_ScaleOffset_t(scales[i], -zero_points[i]) ) # skip dequantize op, e.g. frozen_param -> dq -> conv2d @@ -238,11 +238,11 @@ def make_qnn_per_channel_config(self, node: torch.fx.Node, quant_attrs: Dict): ): quant_config[QCOM_BITWIDTH] = 4 return ( - PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_BW_AXIS_SCALE_OFFSET, + PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_BW_AXIS_SCALE_OFFSET, quant_config, ) return ( - PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET, + PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET, quant_config, ) @@ -257,11 +257,11 @@ def make_qnn_per_tensor_config(self, quant_attrs: Dict): ): quant_config[QCOM_BITWIDTH] = 4 return ( - PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_BW_SCALE_OFFSET, + PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_BW_SCALE_OFFSET, quant_config, ) return ( - PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_SCALE_OFFSET, + PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_SCALE_OFFSET, quant_config, ) @@ -270,7 +270,7 @@ def get_quant_encoding_conf( ) -> Tuple[Any, Dict]: if not node.meta.get(QCOM_QUANT_ATTRS, None): return ( - PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED, + PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED, {}, ) is_input_tensor = node != target_node @@ -321,8 +321,8 @@ def get_quant_tensor_value( def get_tensor_type( self, node: torch.fx.Node, - tensor_type: PyQnnWrapper.Qnn_TensorType_t, - ) -> PyQnnWrapper.Qnn_TensorType_t: + tensor_type: PyQnnManager.Qnn_TensorType_t, + ) -> PyQnnManager.Qnn_TensorType_t: is_input = is_graph_input(node, self.edge_program) or is_mutable_buffer_input( node, self.edge_program ) @@ -333,25 +333,25 @@ def get_tensor_type( node in self.external_ids ), f"Node {node}, is_input: {is_input}, is_output: {is_output}, ext_ids: {self.external_ids.keys()}" if is_input: - return PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_APP_WRITE + return PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_APP_WRITE if is_output: - return PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_APP_READ + return PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_APP_READ if is_parameter(node, self.edge_program): - return PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC + return PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC # dump all tensor, set to app read, and we only dump native tensors if ( self.enable_tensor_dump - and tensor_type == PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + and tensor_type == PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE ): - return PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_APP_READ + return PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_APP_READ return tensor_type def get_data_type( self, tensor: torch.Tensor, quant_config: Dict, - ) -> PyQnnWrapper.Qnn_TensorType_t: + ) -> PyQnnManager.Qnn_TensorType_t: if quant_config: quant_config[QCOM_DTYPE] = deduce_dtype(tensor, quant_config) return QNN_QUANT_TYPE_MAP[quant_config[QCOM_DTYPE]] @@ -400,21 +400,21 @@ def get_tensor_name( def define_custom_tensor_wrapper( self, node_name: str, - tensor_type: PyQnnWrapper.Qnn_TensorType_t, - dtype: PyQnnWrapper.Qnn_DataType_t, - quant_encoding: PyQnnWrapper.Qnn_QuantizationEncoding_t, + tensor_type: PyQnnManager.Qnn_TensorType_t, + dtype: PyQnnManager.Qnn_DataType_t, + quant_encoding: PyQnnManager.Qnn_QuantizationEncoding_t, quant_configs: dict, dims: torch.Size, tensor: torch.Tensor, is_fake_tensor: bool, - nodes_to_wrappers: Dict[str, Dict[int, PyQnnWrapper.TensorWrapper]], + nodes_to_wrappers: Dict[str, Dict[int, PyQnnManager.TensorWrapper]], wrapper_idx: int = 0, - ) -> PyQnnWrapper.TensorWrapper: + ) -> PyQnnManager.TensorWrapper: if cached := nodes_to_wrappers[node_name].get(wrapper_idx, None): return cached if is_fake_tensor: dynamic_dims, nominal_dims = self.get_dynamic_dimension(dims) - tensor_wrapper = PyQnnWrapper.TensorWrapper( + tensor_wrapper = PyQnnManager.TensorWrapper( node_name, tensor_type, dtype, @@ -437,11 +437,11 @@ def define_tensor( tensor_source_node: torch.fx.Node, target_build_node: torch.fx.Node, tensor: torch.Tensor, - tensor_type: PyQnnWrapper.Qnn_TensorType_t, - nodes_to_wrappers: Dict[str, Dict[int, PyQnnWrapper.TensorWrapper]], + tensor_type: PyQnnManager.Qnn_TensorType_t, + nodes_to_wrappers: Dict[str, Dict[int, PyQnnManager.TensorWrapper]], node_name: str = None, wrapper_idx: int = 0, - ) -> PyQnnWrapper.TensorWrapper: + ) -> PyQnnManager.TensorWrapper: """ Covert torch.Tensor to TensorWrapper @@ -467,7 +467,7 @@ def define_tensor( ) dtype = self.get_data_type(tensor, quant_configs) if isinstance(tensor, torch._subclasses.fake_tensor.FakeTensor): - tensor_wrapper = PyQnnWrapper.TensorWrapper( + tensor_wrapper = PyQnnManager.TensorWrapper( tensor_name, tensor_type, dtype, @@ -486,7 +486,7 @@ def define_tensor( tensor_source_node.meta[QCOM_QUANT_ATTRS], quant_configs, ) - tensor_wrapper = PyQnnWrapper.TensorWrapper( + tensor_wrapper = PyQnnManager.TensorWrapper( tensor_name, tensor_type, dtype, @@ -504,7 +504,7 @@ def define_tensor( def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[str, Dict[int, PyQnnWrapper.TensorWrapper]], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[str, Dict[int, PyQnnManager.TensorWrapper]], + ) -> PyQnnManager.PyQnnOpWrapper: """Convert torch.fx.Node to OpWrapper""" raise NotImplementedError("NodeVisitor must be extended!") diff --git a/backends/qualcomm/builders/op_abs.py b/backends/qualcomm/builders/op_abs.py index 1df49b88912..741ba3fa66d 100644 --- a/backends/qualcomm/builders/op_abs.py +++ b/backends/qualcomm/builders/op_abs.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) abs_output_tensors = [output_tensor_wrapper] @@ -41,12 +41,12 @@ def define_node( input_node, node, self.get_tensor(input_node, node), - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) abs_input_tensors = [input_tensor_wrapper] - abs_op = PyQnnWrapper.PyQnnOpWrapper( + abs_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseAbs.op_name, diff --git a/backends/qualcomm/builders/op_adaptive_avg_pool2d.py b/backends/qualcomm/builders/op_adaptive_avg_pool2d.py index 1b0d58482ec..5081fb150f2 100644 --- a/backends/qualcomm/builders/op_adaptive_avg_pool2d.py +++ b/backends/qualcomm/builders/op_adaptive_avg_pool2d.py @@ -6,7 +6,7 @@ import warnings from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -26,8 +26,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -35,7 +35,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -74,11 +74,11 @@ def define_node( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - adaptive_avg_pool2d_op = PyQnnWrapper.PyQnnOpWrapper( + adaptive_avg_pool2d_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpPoolAvg2d.op_name, @@ -89,7 +89,7 @@ def define_node( adaptive_avg_pool2d_op.AddTensorParam( OpPoolAvg2d.param_filter_size, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(filter_shape), filter_shape, np.array( @@ -101,7 +101,7 @@ def define_node( adaptive_avg_pool2d_op.AddTensorParam( OpPoolAvg2d.param_stride, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(stride_shape), stride_shape, np.array( @@ -113,7 +113,7 @@ def define_node( adaptive_avg_pool2d_op.AddTensorParam( OpPoolAvg2d.param_pad_amount, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(padding_shape), padding_shape, np.array( diff --git a/backends/qualcomm/builders/op_adaptive_max_pool2d.py b/backends/qualcomm/builders/op_adaptive_max_pool2d.py index 0db8f42ceb2..7513a0cb6b3 100644 --- a/backends/qualcomm/builders/op_adaptive_max_pool2d.py +++ b/backends/qualcomm/builders/op_adaptive_max_pool2d.py @@ -6,7 +6,7 @@ import warnings from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) users = list(node.users.keys()) @@ -93,11 +93,11 @@ def define_node( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - adaptive_max_pool2d_op = PyQnnWrapper.PyQnnOpWrapper( + adaptive_max_pool2d_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpPoolMax2d.op_name, @@ -108,7 +108,7 @@ def define_node( adaptive_max_pool2d_op.AddTensorParam( OpPoolMax2d.param_filter_size, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(filter_shape), filter_shape, np.array( @@ -120,7 +120,7 @@ def define_node( adaptive_max_pool2d_op.AddTensorParam( OpPoolMax2d.param_stride, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(stride_shape), stride_shape, np.array( @@ -132,7 +132,7 @@ def define_node( adaptive_max_pool2d_op.AddTensorParam( OpPoolMax2d.param_pad_amount, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(padding_shape), padding_shape, np.array( @@ -144,7 +144,7 @@ def define_node( adaptive_max_pool2d_op.AddScalarParam( OpPoolMax2d.param_rounding_mode, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(mode)}, ) diff --git a/backends/qualcomm/builders/op_add.py b/backends/qualcomm/builders/op_add.py index d2f4a39fc3d..3c1c9beb79e 100644 --- a/backends/qualcomm/builders/op_add.py +++ b/backends/qualcomm/builders/op_add.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) add_output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -51,7 +51,7 @@ def define_node( ) add_input_tensors.append(input_tensor_wrapper) - add_op = PyQnnWrapper.PyQnnOpWrapper( + add_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseAdd.op_name, diff --git a/backends/qualcomm/builders/op_amax.py b/backends/qualcomm/builders/op_amax.py index d0335f95463..5305528996b 100644 --- a/backends/qualcomm/builders/op_amax.py +++ b/backends/qualcomm/builders/op_amax.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -60,11 +60,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - reduce_max_op = PyQnnWrapper.PyQnnOpWrapper( + reduce_max_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReduceMax.op_name, @@ -73,7 +73,7 @@ def define_node( reduce_max_op.AddOutputTensors([output_tensor_wrapper]) reduce_max_op.AddTensorParam( OpReduceMax.param_axes, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(mean_dims_shape), mean_dims_shape, np.array(mean_dims, dtype=np.uint32), @@ -83,7 +83,7 @@ def define_node( keep_dims = cast(bool, node.args[2]) reduce_max_op.AddScalarParam( OpReduceMax.param_keep_dims, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: keep_dims}, ) diff --git a/backends/qualcomm/builders/op_amin.py b/backends/qualcomm/builders/op_amin.py index 142340dbae0..c8589591a1a 100644 --- a/backends/qualcomm/builders/op_amin.py +++ b/backends/qualcomm/builders/op_amin.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -60,11 +60,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - reduce_min_op = PyQnnWrapper.PyQnnOpWrapper( + reduce_min_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReduceMin.op_name, @@ -73,7 +73,7 @@ def define_node( reduce_min_op.AddOutputTensors([output_tensor_wrapper]) reduce_min_op.AddTensorParam( OpReduceMin.param_axes, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(mean_dims_shape), mean_dims_shape, np.array(mean_dims, dtype=np.uint32), @@ -83,7 +83,7 @@ def define_node( keep_dims = cast(bool, node.args[2]) reduce_min_op.AddScalarParam( OpReduceMin.param_keep_dims, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: keep_dims}, ) diff --git a/backends/qualcomm/builders/op_and.py b/backends/qualcomm/builders/op_and.py index cf06ef2fd66..b3736025414 100644 --- a/backends/qualcomm/builders/op_and.py +++ b/backends/qualcomm/builders/op_and.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) and_output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -50,7 +50,7 @@ def define_node( nodes_to_wrappers, ) and_input_tensors.append(input_tensor_wrapper) - and_op = PyQnnWrapper.PyQnnOpWrapper( + and_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseAnd.op_name, diff --git a/backends/qualcomm/builders/op_arange.py b/backends/qualcomm/builders/op_arange.py index e8c4c7d5267..0a95d55dca3 100644 --- a/backends/qualcomm/builders/op_arange.py +++ b/backends/qualcomm/builders/op_arange.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -23,8 +23,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: start, end = node.args[0:2] step = node.args[2] if len(node.args) > 2 else 1 out_tensor = torch.arange(start, end, step) @@ -36,6 +36,6 @@ def define_node( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) diff --git a/backends/qualcomm/builders/op_argmax.py b/backends/qualcomm/builders/op_argmax.py index e81b0dd1d95..60293e0c104 100644 --- a/backends/qualcomm/builders/op_argmax.py +++ b/backends/qualcomm/builders/op_argmax.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch from executorch.backends.qualcomm.utils.constants import QCOM_AXIS_ORDER, QCOM_DATA @@ -25,8 +25,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) output_tensor = self.get_tensor(node, node) @@ -34,7 +34,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) argmax_input_tensors = [argmax_inp_tensor_wrapper] @@ -42,7 +42,7 @@ def define_node( node, node, output_tensor.to(torch.int32), - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) argmax_output_tensors = [argmax_out_tensor_wrapper] @@ -53,7 +53,7 @@ def define_node( if QCOM_AXIS_ORDER in node.meta: dim = node.meta[QCOM_AXIS_ORDER].index(dim) - argmax_op = PyQnnWrapper.PyQnnOpWrapper( + argmax_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpArgmax.op_name, @@ -63,7 +63,7 @@ def define_node( argmax_op.AddScalarParam( OpArgmax.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(dim)}, ) @@ -71,7 +71,7 @@ def define_node( keep_dims = cast(bool, node.args[2]) argmax_op.AddScalarParam( OpArgmax.param_keep_dims, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: keep_dims}, ) diff --git a/backends/qualcomm/builders/op_argmin.py b/backends/qualcomm/builders/op_argmin.py index a9fa2021bb0..d66a4300b96 100644 --- a/backends/qualcomm/builders/op_argmin.py +++ b/backends/qualcomm/builders/op_argmin.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch from executorch.backends.qualcomm.utils.constants import QCOM_AXIS_ORDER, QCOM_DATA @@ -25,8 +25,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) output_tensor = self.get_tensor(node, node) @@ -34,7 +34,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) argmin_input_tensors = [argmin_inp_tensor_wrapper] @@ -42,7 +42,7 @@ def define_node( node, node, output_tensor.to(torch.int32), - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) argmin_output_tensors = [argmin_out_tensor_wrapper] @@ -53,7 +53,7 @@ def define_node( if QCOM_AXIS_ORDER in node.meta: dim = node.meta[QCOM_AXIS_ORDER].index(dim) - argmin_op = PyQnnWrapper.PyQnnOpWrapper( + argmin_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpArgmin.op_name, @@ -63,7 +63,7 @@ def define_node( argmin_op.AddScalarParam( OpArgmin.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(dim)}, ) @@ -71,7 +71,7 @@ def define_node( keep_dims = cast(bool, node.args[2]) argmin_op.AddScalarParam( OpArgmin.param_keep_dims, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: keep_dims}, ) diff --git a/backends/qualcomm/builders/op_asin.py b/backends/qualcomm/builders/op_asin.py index ff50380e62c..1907890c69a 100644 --- a/backends/qualcomm/builders/op_asin.py +++ b/backends/qualcomm/builders/op_asin.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree.from typing import cast, Dict from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from .node_visitor import NodeVisitor @@ -24,15 +24,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -41,11 +41,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - asin_op = PyQnnWrapper.PyQnnOpWrapper( + asin_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseAsin.op_name, diff --git a/backends/qualcomm/builders/op_atan.py b/backends/qualcomm/builders/op_atan.py index 83c47b9103d..f208f1bedb5 100644 --- a/backends/qualcomm/builders/op_atan.py +++ b/backends/qualcomm/builders/op_atan.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from .node_visitor import NodeVisitor @@ -23,15 +23,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -40,11 +40,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - atan_op = PyQnnWrapper.PyQnnOpWrapper( + atan_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseAtan.op_name, diff --git a/backends/qualcomm/builders/op_avg_pool2d.py b/backends/qualcomm/builders/op_avg_pool2d.py index 6e0f70474ea..4e44c333f6e 100644 --- a/backends/qualcomm/builders/op_avg_pool2d.py +++ b/backends/qualcomm/builders/op_avg_pool2d.py @@ -6,7 +6,7 @@ import warnings from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -33,15 +33,15 @@ def _get_filter_size(self, node): def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -50,7 +50,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -112,7 +112,7 @@ def define_node( ) return - avg_pool2d_op = PyQnnWrapper.PyQnnOpWrapper( + avg_pool2d_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpPoolAvg2d.op_name, @@ -122,7 +122,7 @@ def define_node( avg_pool2d_op.AddTensorParam( OpPoolAvg2d.param_filter_size, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(filter_size_shape), filter_size_shape, np.array( @@ -133,7 +133,7 @@ def define_node( ) avg_pool2d_op.AddTensorParam( OpPoolAvg2d.param_stride, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(stride_shape), stride_shape, np.array( @@ -144,7 +144,7 @@ def define_node( ) avg_pool2d_op.AddTensorParam( OpPoolAvg2d.param_pad_amount, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(padding_shape), padding_shape, np.array( @@ -156,12 +156,12 @@ def define_node( avg_pool2d_op.AddScalarParam( OpPoolAvg2d.param_rounding_mode, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(mode)}, ) avg_pool2d_op.AddScalarParam( OpPoolAvg2d.param_count_pad_for_edges, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: count_include_pad}, ) diff --git a/backends/qualcomm/builders/op_avg_pool3d.py b/backends/qualcomm/builders/op_avg_pool3d.py index 9d585eaeecb..5e27ce2b4c1 100644 --- a/backends/qualcomm/builders/op_avg_pool3d.py +++ b/backends/qualcomm/builders/op_avg_pool3d.py @@ -6,7 +6,7 @@ import warnings from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,8 +27,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -36,7 +36,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -88,11 +88,11 @@ def define_node( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - avg_pool3d_op = PyQnnWrapper.PyQnnOpWrapper( + avg_pool3d_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpPoolAvg3d.op_name, @@ -103,7 +103,7 @@ def define_node( avg_pool3d_op.AddTensorParam( OpPoolAvg3d.param_filter_size, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(filter_size_shape), filter_size_shape, np.array( @@ -115,7 +115,7 @@ def define_node( avg_pool3d_op.AddTensorParam( OpPoolAvg3d.param_stride, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(stride_shape), stride_shape, np.array( @@ -127,7 +127,7 @@ def define_node( avg_pool3d_op.AddTensorParam( OpPoolAvg3d.param_pad_amount, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(padding_shape), padding_shape, np.array( @@ -139,13 +139,13 @@ def define_node( avg_pool3d_op.AddScalarParam( OpPoolAvg3d.param_count_pad_for_edges, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: count_pad_for_edges}, ) avg_pool3d_op.AddScalarParam( OpPoolAvg3d.param_rounding_mode, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(mode)}, ) @@ -162,15 +162,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) # NOTE: This operator is layout sensitive, so the input tensor shape is always N,D,H,W,C. @@ -235,11 +235,11 @@ def define_node( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - adaptive_avg_pool3d_op = PyQnnWrapper.PyQnnOpWrapper( + adaptive_avg_pool3d_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpPoolAvg3d.op_name, @@ -250,7 +250,7 @@ def define_node( adaptive_avg_pool3d_op.AddTensorParam( OpPoolAvg3d.param_filter_size, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(filter_shape), filter_shape, np.array( @@ -262,7 +262,7 @@ def define_node( adaptive_avg_pool3d_op.AddTensorParam( OpPoolAvg3d.param_stride, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(stride_shape), stride_shape, np.array( @@ -274,7 +274,7 @@ def define_node( adaptive_avg_pool3d_op.AddTensorParam( OpPoolAvg3d.param_pad_amount, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(padding_shape), padding_shape, np.array( @@ -286,13 +286,13 @@ def define_node( adaptive_avg_pool3d_op.AddScalarParam( OpPoolAvg3d.param_count_pad_for_edges, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: count_pad_for_edges}, ) adaptive_avg_pool3d_op.AddScalarParam( OpPoolAvg3d.param_rounding_mode, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(mode)}, ) diff --git a/backends/qualcomm/builders/op_batch_norm.py b/backends/qualcomm/builders/op_batch_norm.py index 25a9c2b123e..eecc32113b1 100644 --- a/backends/qualcomm/builders/op_batch_norm.py +++ b/backends/qualcomm/builders/op_batch_norm.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from executorch.backends.qualcomm.utils.constants import ( @@ -54,8 +54,8 @@ def try_dequantize(self, node: torch.fx.Node, tensor: torch.Tensor): def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -71,7 +71,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) batch_norm_input_tensors = [input_tensor_wrapper] @@ -81,7 +81,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) batch_norm_output_tensors = [output_tensor_wrapper] @@ -117,7 +117,7 @@ def define_node( filter_node, node, filter_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) batch_norm_input_tensors.append(filter_tensor_wrapper) @@ -135,12 +135,12 @@ def define_node( bias_node, node, bias_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) batch_norm_input_tensors.append(bias_tensor_wrapper) - batch_norm_op = PyQnnWrapper.PyQnnOpWrapper( + batch_norm_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpBatchnorm.op_name, diff --git a/backends/qualcomm/builders/op_binary.py b/backends/qualcomm/builders/op_binary.py index 4f4d8b9b560..2421fcb9af5 100644 --- a/backends/qualcomm/builders/op_binary.py +++ b/backends/qualcomm/builders/op_binary.py @@ -6,7 +6,7 @@ import warnings from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch from executorch.backends.qualcomm.utils.constants import QCOM_DATA @@ -33,14 +33,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) binary_output_tensors = [output_tensor_wrapper] @@ -49,7 +49,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -60,7 +60,7 @@ def define_node( ) binary_input_tensors.append(input_tensor_wrapper) - binary_op = PyQnnWrapper.PyQnnOpWrapper( + binary_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseBinary.op_name, @@ -77,7 +77,7 @@ def define_node( binary_op.AddScalarParam( OpElementWiseBinary.param_operation, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(QNN_BINARY_OPERATOR[node.target])}, ) diff --git a/backends/qualcomm/builders/op_bmm.py b/backends/qualcomm/builders/op_bmm.py index 92c8f1dde3e..191c4497b2c 100644 --- a/backends/qualcomm/builders/op_bmm.py +++ b/backends/qualcomm/builders/op_bmm.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,8 +24,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: bmm_input_tensors = [] for index in range(2): input_node = self.get_node(node.args[index]) @@ -35,7 +35,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) bmm_input_tensors.append(input_tensor_wrapper) @@ -45,12 +45,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) bmm_output_tensors = [output_tensor_wrapper] - bmm_op = PyQnnWrapper.PyQnnOpWrapper( + bmm_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpMatMul.op_name ) bmm_op.AddInputTensors(bmm_input_tensors) diff --git a/backends/qualcomm/builders/op_cat.py b/backends/qualcomm/builders/op_cat.py index 644b087ab9c..31045426959 100644 --- a/backends/qualcomm/builders/op_cat.py +++ b/backends/qualcomm/builders/op_cat.py @@ -6,7 +6,7 @@ import warnings from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,8 +27,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_nodes = cast(List[torch.fx.Node], node.args[0]) input_tensor_wrappers = [] @@ -40,7 +40,7 @@ def define_node( source_input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) ) @@ -57,7 +57,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -72,7 +72,7 @@ def define_node( if QCOM_AXIS_ORDER in node.meta: axis = node.meta[QCOM_AXIS_ORDER].index(axis) - concat_op = PyQnnWrapper.PyQnnOpWrapper( + concat_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpConcat.op_name, @@ -82,7 +82,7 @@ def define_node( concat_op.AddScalarParam( OpConcat.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(axis)}, ) diff --git a/backends/qualcomm/builders/op_ceil.py b/backends/qualcomm/builders/op_ceil.py index 6b85592165c..58397b4382c 100644 --- a/backends/qualcomm/builders/op_ceil.py +++ b/backends/qualcomm/builders/op_ceil.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,15 +24,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -41,11 +41,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - ceil_op = PyQnnWrapper.PyQnnOpWrapper( + ceil_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseCeil.op_name, diff --git a/backends/qualcomm/builders/op_clamp.py b/backends/qualcomm/builders/op_clamp.py index 1e13b70f78e..b19790e7735 100644 --- a/backends/qualcomm/builders/op_clamp.py +++ b/backends/qualcomm/builders/op_clamp.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -26,15 +26,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -55,11 +55,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - clamp_op = PyQnnWrapper.PyQnnOpWrapper( + clamp_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReluMinMax.op_name, @@ -68,12 +68,12 @@ def define_node( clamp_op.AddOutputTensors([output_tensor_wrapper]) clamp_op.AddScalarParam( OpReluMinMax.param_max_value, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, {QCOM_DATA: np.float32(output_max)}, ) clamp_op.AddScalarParam( OpReluMinMax.param_min_value, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, {QCOM_DATA: np.float32(output_min)}, ) diff --git a/backends/qualcomm/builders/op_conv.py b/backends/qualcomm/builders/op_conv.py index 317a3269ede..aadb893c8ff 100644 --- a/backends/qualcomm/builders/op_conv.py +++ b/backends/qualcomm/builders/op_conv.py @@ -6,7 +6,7 @@ from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch from executorch.backends.qualcomm.utils.constants import QCOM_DATA, QCOM_QUANT_ATTRS @@ -47,7 +47,7 @@ def _add_conv_op_parameter( output_padding_shape=None, transpose_conv=False, groups=None, - ) -> PyQnnWrapper.PyQnnOpWrapper: + ) -> PyQnnManager.PyQnnOpWrapper: """ This function is shared among Conv1D, Conv2D, and DepthWise Conv2D as most of the required parameters overlaps. """ @@ -55,7 +55,7 @@ def _add_conv_op_parameter( conv_op.AddOutputTensors(conv_output_tensors) conv_op.AddTensorParam( OP.param_stride, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(stride_shape), stride_shape, np.array(stride, dtype=np.uint32), @@ -63,7 +63,7 @@ def _add_conv_op_parameter( ) conv_op.AddTensorParam( OP.param_pad_amount, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(padding_shape), padding_shape, np.array( @@ -76,7 +76,7 @@ def _add_conv_op_parameter( if transpose_conv: conv_op.AddTensorParam( OP.param_output_padding, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(output_padding_shape), output_padding_shape, np.array(output_padding, dtype=np.uint32), @@ -85,7 +85,7 @@ def _add_conv_op_parameter( else: conv_op.AddTensorParam( OP.param_dilation, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(dilation_shape), dilation_shape, np.array(dilation, dtype=np.uint32), @@ -95,7 +95,7 @@ def _add_conv_op_parameter( if groups is not None: conv_op.AddScalarParam( OP.param_group, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(groups)}, ) @@ -127,8 +127,8 @@ def _reduce_bias_scales( def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[str, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[str, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) assert ( @@ -144,7 +144,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -171,7 +171,7 @@ def define_node( filter_node, node, filter_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) conv_input_tensors = [input_tensor_wrapper, filter_tensor_wrapper] @@ -192,7 +192,7 @@ def define_node( bias_node, node, bias_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) conv_input_tensors.append(bias_tensor_wrapper) @@ -201,7 +201,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) conv_output_tensors = [output_tensor_wrapper] @@ -238,7 +238,7 @@ def define_node( else: op_class = OpConv2d if is_conv2d else OpConv3d - conv_op = PyQnnWrapper.PyQnnOpWrapper( + conv_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, op_class.op_name, diff --git a/backends/qualcomm/builders/op_copy.py b/backends/qualcomm/builders/op_copy.py index 164c910835e..a1caa1c98a2 100644 --- a/backends/qualcomm/builders/op_copy.py +++ b/backends/qualcomm/builders/op_copy.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from executorch.backends.qualcomm.utils.constants import QCOM_QUANT_ATTRS @@ -25,15 +25,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[1]) input_tensor = self.get_tensor(input_node, node) copy_inp_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -48,12 +48,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) copy_output_tensors = [output_tensor_wrapper] - copy_op = PyQnnWrapper.PyQnnOpWrapper( + copy_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReshape.op_name, diff --git a/backends/qualcomm/builders/op_cos.py b/backends/qualcomm/builders/op_cos.py index 9ff11d86dda..9701f9a211b 100644 --- a/backends/qualcomm/builders/op_cos.py +++ b/backends/qualcomm/builders/op_cos.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,15 +24,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -41,11 +41,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - cos_op = PyQnnWrapper.PyQnnOpWrapper( + cos_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseCos.op_name, diff --git a/backends/qualcomm/builders/op_cum_sum.py b/backends/qualcomm/builders/op_cum_sum.py index da2b025fe9f..5668fb2ab70 100644 --- a/backends/qualcomm/builders/op_cum_sum.py +++ b/backends/qualcomm/builders/op_cum_sum.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -36,15 +36,15 @@ def get_param(self, node, input_tensor): def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -57,11 +57,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - cumsum_op = PyQnnWrapper.PyQnnOpWrapper( + cumsum_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpCumulativeSum.op_name, @@ -70,17 +70,17 @@ def define_node( cumsum_op.AddOutputTensors([output_tensor_wrapper]) cumsum_op.AddScalarParam( OpCumulativeSum.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: dim}, ) cumsum_op.AddScalarParam( OpCumulativeSum.param_exclusive, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: False}, ) cumsum_op.AddScalarParam( OpCumulativeSum.param_reverse, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: False}, ) diff --git a/backends/qualcomm/builders/op_custom_op.py b/backends/qualcomm/builders/op_custom_op.py index 52a15ef95f2..203e3a2ac64 100644 --- a/backends/qualcomm/builders/op_custom_op.py +++ b/backends/qualcomm/builders/op_custom_op.py @@ -6,7 +6,7 @@ import warnings from typing import Dict, Iterable -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -32,9 +32,9 @@ def __init__(self, op_package_info: QnnExecuTorchOpPackageInfo, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: - custom_op = PyQnnWrapper.PyQnnOpWrapper( + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: + custom_op = PyQnnManager.PyQnnOpWrapper( node.name, self.op_package_info.op_package_name, self.op_package_info.qnn_op_type_name, @@ -57,7 +57,7 @@ def define_node( arg, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) custom_input_tensors.append(input_tensor_wrapper) @@ -83,7 +83,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) custom_output_tensors = [output_tensor_wrapper] diff --git a/backends/qualcomm/builders/op_depth_to_space.py b/backends/qualcomm/builders/op_depth_to_space.py index 908e0949162..5e1dbe639c5 100644 --- a/backends/qualcomm/builders/op_depth_to_space.py +++ b/backends/qualcomm/builders/op_depth_to_space.py @@ -6,7 +6,7 @@ from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -44,7 +44,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -54,7 +54,7 @@ def define_node( block_size = np.array(block_size, dtype=np.uint32) block_size_shape = [2] - depth_to_space_op = PyQnnWrapper.PyQnnOpWrapper( + depth_to_space_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpDepthToSpace.op_name, @@ -63,7 +63,7 @@ def define_node( depth_to_space_op.AddOutputTensors([output_tensor_wrapper]) depth_to_space_op.AddTensorParam( OpDepthToSpace.param_block_size, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(block_size.shape), block_size_shape, block_size, @@ -71,7 +71,7 @@ def define_node( ) depth_to_space_op.AddScalarParam( OpDepthToSpace.param_mode, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(OpDepthToSpace.Mode.CRD)}, ) diff --git a/backends/qualcomm/builders/op_dequantize.py b/backends/qualcomm/builders/op_dequantize.py index c4d9b8c29a4..31801c19aaf 100644 --- a/backends/qualcomm/builders/op_dequantize.py +++ b/backends/qualcomm/builders/op_dequantize.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -21,8 +21,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: dequant_input_tensors = [] input_node = node.args[0] input_tensor = self.get_tensor(input_node, node) @@ -30,7 +30,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) dequant_input_tensors.append(inp_tensor_wrapper) @@ -40,12 +40,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) dequant_output_tensors = [output_tensor_wrapper] - dequant_op = PyQnnWrapper.PyQnnOpWrapper( + dequant_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpDequantize.op_name, diff --git a/backends/qualcomm/builders/op_div.py b/backends/qualcomm/builders/op_div.py index 9fc4a9302b0..1467147d390 100644 --- a/backends/qualcomm/builders/op_div.py +++ b/backends/qualcomm/builders/op_div.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) div_output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -51,7 +51,7 @@ def define_node( ) div_input_tensors.append(input_tensor_wrapper) - div_op = PyQnnWrapper.PyQnnOpWrapper( + div_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseDivide.op_name, diff --git a/backends/qualcomm/builders/op_elu.py b/backends/qualcomm/builders/op_elu.py index 215fe654948..cfbb011f2f5 100644 --- a/backends/qualcomm/builders/op_elu.py +++ b/backends/qualcomm/builders/op_elu.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -26,8 +26,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: # tensor input input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -36,7 +36,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) elu_input_tensors = [input_tensor_wrapper] @@ -46,12 +46,12 @@ def define_node( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) elu_output_tensors = [output_tensor_wrapper] - elu_op = PyQnnWrapper.PyQnnOpWrapper( + elu_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElu.op_name, @@ -61,7 +61,7 @@ def define_node( if len(node.args) > 1: elu_op.AddScalarParam( OpElu.param_alpha, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, {QCOM_DATA: np.float32(node.args[1])}, ) diff --git a/backends/qualcomm/builders/op_embedding.py b/backends/qualcomm/builders/op_embedding.py index 45adc20fa79..03a33f14bec 100644 --- a/backends/qualcomm/builders/op_embedding.py +++ b/backends/qualcomm/builders/op_embedding.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: weight_node = self.get_node(node.args[0]) weight_tensor = get_parameter(weight_node, self.edge_program) weight_tensor_wrapper = self.define_tensor( weight_node, node, weight_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) @@ -45,7 +45,7 @@ def define_node( indices_node, node, indices_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -56,12 +56,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) gather_output_tensors = [output_tensor_wrapper] - gather_op = PyQnnWrapper.PyQnnOpWrapper( + gather_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpGather.op_name, @@ -72,7 +72,7 @@ def define_node( # For now, default axis is zero. gather_op.AddScalarParam( OpGather.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_INT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_INT_32, {QCOM_DATA: np.int32(0)}, ) diff --git a/backends/qualcomm/builders/op_eq.py b/backends/qualcomm/builders/op_eq.py index fcf3213d3a9..98fb34834e5 100644 --- a/backends/qualcomm/builders/op_eq.py +++ b/backends/qualcomm/builders/op_eq.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -51,7 +51,7 @@ def define_node( ) input_tensors.append(input_tensor_wrapper) - eq_op = PyQnnWrapper.PyQnnOpWrapper( + eq_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseEqual.op_name, diff --git a/backends/qualcomm/builders/op_exp.py b/backends/qualcomm/builders/op_exp.py index 9a80e7fb4f4..333c57bcf63 100644 --- a/backends/qualcomm/builders/op_exp.py +++ b/backends/qualcomm/builders/op_exp.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,8 +24,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: # tensor input input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -34,7 +34,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) exp_input_tensors = [input_tensor_wrapper] @@ -44,12 +44,12 @@ def define_node( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) exp_output_tensors = [output_tensor_wrapper] - exp_op = PyQnnWrapper.PyQnnOpWrapper( + exp_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseExp.op_name, diff --git a/backends/qualcomm/builders/op_expand.py b/backends/qualcomm/builders/op_expand.py index 01a8da42752..1aadb17e513 100644 --- a/backends/qualcomm/builders/op_expand.py +++ b/backends/qualcomm/builders/op_expand.py @@ -6,7 +6,7 @@ import warnings from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -26,15 +26,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -43,7 +43,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -66,7 +66,7 @@ def define_node( if sizes[i] != -1 and shape[i] == 1: multiples[i] = sizes[i] - tile_op = PyQnnWrapper.PyQnnOpWrapper( + tile_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpTile.op_name, @@ -75,7 +75,7 @@ def define_node( tile_op.AddOutputTensors([output_tensor_wrapper]) tile_op.AddTensorParam( OpTile.param_multiples, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(multiples_shape), multiples_shape, np.array(multiples, dtype=np.uint32), diff --git a/backends/qualcomm/builders/op_flip.py b/backends/qualcomm/builders/op_flip.py index 16d68942d31..3eea5867ac8 100644 --- a/backends/qualcomm/builders/op_flip.py +++ b/backends/qualcomm/builders/op_flip.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,11 +27,11 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -46,7 +46,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) ranges = [] @@ -62,7 +62,7 @@ def define_node( ranges.extend([0, size, 1]) range_shape = [input_tensor.dim(), 3] - stride_slice_op = PyQnnWrapper.PyQnnOpWrapper( + stride_slice_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpStridedSlice.op_name, @@ -71,7 +71,7 @@ def define_node( stride_slice_op.AddOutputTensors([output_tensor_wrapper]) stride_slice_op.AddTensorParam( OpStridedSlice.param_ranges, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_INT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_INT_32, len(range_shape), range_shape, np.array(ranges, dtype=np.int32), diff --git a/backends/qualcomm/builders/op_floor.py b/backends/qualcomm/builders/op_floor.py index 3d69389686e..25780301c3d 100644 --- a/backends/qualcomm/builders/op_floor.py +++ b/backends/qualcomm/builders/op_floor.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from .node_visitor import NodeVisitor @@ -23,15 +23,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) floor_inp_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) floor_input_tensors = [floor_inp_tensor_wrapper] @@ -41,12 +41,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) floor_output_tensors = [output_tensor_wrapper] - floor_op = PyQnnWrapper.PyQnnOpWrapper( + floor_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseFloor.op_name, diff --git a/backends/qualcomm/builders/op_full.py b/backends/qualcomm/builders/op_full.py index d58efd77791..5ac2e95c57b 100644 --- a/backends/qualcomm/builders/op_full.py +++ b/backends/qualcomm/builders/op_full.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -23,8 +23,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = torch.full( node.args[0], node.args[1], dtype=node.meta["val"].dtype ) @@ -36,6 +36,6 @@ def define_node( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) diff --git a/backends/qualcomm/builders/op_full_like.py b/backends/qualcomm/builders/op_full_like.py index 69609d887aa..66f80ecc80a 100644 --- a/backends/qualcomm/builders/op_full_like.py +++ b/backends/qualcomm/builders/op_full_like.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -23,8 +23,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: in_tensor = node.args[0].meta["val"] ref_tensor = torch.zeros(in_tensor.shape, dtype=in_tensor.dtype) out_tensor = torch.full_like(ref_tensor, node.args[1]) @@ -36,6 +36,6 @@ def define_node( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) diff --git a/backends/qualcomm/builders/op_gather.py b/backends/qualcomm/builders/op_gather.py index 140d2a79caf..ed6f3f0a56b 100644 --- a/backends/qualcomm/builders/op_gather.py +++ b/backends/qualcomm/builders/op_gather.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -26,15 +26,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = node.args[0] input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -46,7 +46,7 @@ def define_node( indices_node, node, indices_tensor.to(torch.int32), - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) gather_input_tensors = [input_tensor_wrapper, indices_tensor_wrapper] @@ -55,12 +55,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) gather_output_tensors = [output_tensor_wrapper] - gather_op = PyQnnWrapper.PyQnnOpWrapper( + gather_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpGatherElements.op_name, @@ -69,7 +69,7 @@ def define_node( gather_op.AddOutputTensors(gather_output_tensors) gather_op.AddScalarParam( OpGatherElements.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(dim)}, ) diff --git a/backends/qualcomm/builders/op_ge.py b/backends/qualcomm/builders/op_ge.py index 6c5671ff5f2..2aeb5a87d71 100644 --- a/backends/qualcomm/builders/op_ge.py +++ b/backends/qualcomm/builders/op_ge.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -51,7 +51,7 @@ def define_node( ) input_tensors.append(input_tensor_wrapper) - ge_op = PyQnnWrapper.PyQnnOpWrapper( + ge_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseGreaterEqual.op_name, diff --git a/backends/qualcomm/builders/op_gelu.py b/backends/qualcomm/builders/op_gelu.py index 3d111f0cf98..8d74eaaef16 100644 --- a/backends/qualcomm/builders/op_gelu.py +++ b/backends/qualcomm/builders/op_gelu.py @@ -6,7 +6,7 @@ from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -25,15 +25,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -42,11 +42,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - gelu_op = PyQnnWrapper.PyQnnOpWrapper( + gelu_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpGelu.op_name, diff --git a/backends/qualcomm/builders/op_grid_sampler_2d.py b/backends/qualcomm/builders/op_grid_sampler_2d.py index 6b6e7bf8610..4327aa81fe8 100644 --- a/backends/qualcomm/builders/op_grid_sampler_2d.py +++ b/backends/qualcomm/builders/op_grid_sampler_2d.py @@ -6,7 +6,7 @@ import warnings from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -28,8 +28,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: grid_sample_op_list = [] input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -37,7 +37,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -47,7 +47,7 @@ def define_node( grid_node, node, grid_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -79,7 +79,7 @@ def define_node( grid_dtype = ( QNN_TENSOR_TYPE_MAP[grid_tensor.dtype] if grid_quant_encoding - == PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED + == PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED else QNN_QUANT_TYPE_MAP[ ( torch.uint16 @@ -92,7 +92,7 @@ def define_node( permute_output_tensor = grid_tensor.permute(dims=dims_shape_back) transpose_output_tensor_wrapper = self.define_custom_tensor_wrapper( node_name=node.name + "_transpose", - tensor_type=PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + tensor_type=PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, dtype=grid_dtype, quant_encoding=grid_quant_encoding, quant_configs=grid_quant_configs, @@ -104,7 +104,7 @@ def define_node( permute_order = cast(List[int], dims_shape_back) permute_order_shape = [len(permute_order)] - transpose_op = PyQnnWrapper.PyQnnOpWrapper( + transpose_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpTranspose.op_name, @@ -113,7 +113,7 @@ def define_node( transpose_op.AddOutputTensors([transpose_output_tensor_wrapper]) transpose_op.AddTensorParam( OpTranspose.param_perm, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(permute_order_shape), permute_order_shape, np.array(permute_order, dtype=np.uint32), @@ -126,7 +126,7 @@ def define_node( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -134,7 +134,7 @@ def define_node( padding_mode = node.args[3] if len(node.args) > 3 else 0 interpo_mode = node.args[2] if len(node.args) > 2 else 0 - grid_sample_op = PyQnnWrapper.PyQnnOpWrapper( + grid_sample_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpGridSample.op_name, @@ -145,17 +145,17 @@ def define_node( grid_sample_op.AddOutputTensors([output_tensor_wrapper]) grid_sample_op.AddScalarParam( OpGridSample.param_align_corners, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: align_corners}, ) grid_sample_op.AddScalarParam( OpGridSample.param_mode, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(interpo_mode)}, ) grid_sample_op.AddScalarParam( OpGridSample.param_padding_mode, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(padding_mode)}, ) grid_sample_op_list.append(grid_sample_op) diff --git a/backends/qualcomm/builders/op_group_norm.py b/backends/qualcomm/builders/op_group_norm.py index c492616d999..7a18373aa6c 100644 --- a/backends/qualcomm/builders/op_group_norm.py +++ b/backends/qualcomm/builders/op_group_norm.py @@ -6,7 +6,7 @@ from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -28,15 +28,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -46,7 +46,7 @@ def define_node( weight_node, node, weight_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) @@ -56,7 +56,7 @@ def define_node( bias_node, node, bias_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) group = node.args[6] @@ -67,11 +67,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - group_norm_op = PyQnnWrapper.PyQnnOpWrapper( + group_norm_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpGroupNorm.op_name, @@ -82,12 +82,12 @@ def define_node( group_norm_op.AddOutputTensors([output_tensor_wrapper]) group_norm_op.AddScalarParam( OpGroupNorm.param_epsilon, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, {QCOM_DATA: np.float32(epsilon)}, ) group_norm_op.AddScalarParam( OpGroupNorm.param_group, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(group)}, ) diff --git a/backends/qualcomm/builders/op_gt.py b/backends/qualcomm/builders/op_gt.py index e296589af5a..66b94fa3b75 100644 --- a/backends/qualcomm/builders/op_gt.py +++ b/backends/qualcomm/builders/op_gt.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -51,7 +51,7 @@ def define_node( ) input_tensors.append(input_tensor_wrapper) - gt_op = PyQnnWrapper.PyQnnOpWrapper( + gt_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseGreater.op_name, diff --git a/backends/qualcomm/builders/op_hardsigmoid.py b/backends/qualcomm/builders/op_hardsigmoid.py index 70ac35828d8..ca834358bf8 100644 --- a/backends/qualcomm/builders/op_hardsigmoid.py +++ b/backends/qualcomm/builders/op_hardsigmoid.py @@ -6,7 +6,7 @@ from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -44,11 +44,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - hardsigmoid_op = PyQnnWrapper.PyQnnOpWrapper( + hardsigmoid_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseNeuron.op_name, @@ -59,19 +59,19 @@ def define_node( # The operation enum of hardsigmoid in QNN hardsigmoid_op.AddScalarParam( OpElementWiseNeuron.param_operation, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(2)}, ) # The parameter used in Pytorch definition for hardsigmoid hardsigmoid_op.AddScalarParam( OpElementWiseNeuron.param_alpha, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, {QCOM_DATA: np.float32(1 / 6)}, ) hardsigmoid_op.AddScalarParam( OpElementWiseNeuron.param_beta, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, {QCOM_DATA: np.float32(1 / 2)}, ) diff --git a/backends/qualcomm/builders/op_hardswish.py b/backends/qualcomm/builders/op_hardswish.py index 8a8fa25847d..2fa8a6276c2 100644 --- a/backends/qualcomm/builders/op_hardswish.py +++ b/backends/qualcomm/builders/op_hardswish.py @@ -6,7 +6,7 @@ from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -25,15 +25,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -42,11 +42,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - hardswish_op = PyQnnWrapper.PyQnnOpWrapper( + hardswish_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpHardSwish.op_name, diff --git a/backends/qualcomm/builders/op_hardtanh.py b/backends/qualcomm/builders/op_hardtanh.py index 755e45f0e3b..3e321b4e028 100644 --- a/backends/qualcomm/builders/op_hardtanh.py +++ b/backends/qualcomm/builders/op_hardtanh.py @@ -6,7 +6,7 @@ from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -54,11 +54,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - hardtanh_op = PyQnnWrapper.PyQnnOpWrapper( + hardtanh_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReluMinMax.op_name, @@ -67,12 +67,12 @@ def define_node( hardtanh_op.AddOutputTensors([output_tensor_wrapper]) hardtanh_op.AddScalarParam( OpReluMinMax.param_max_value, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, {QCOM_DATA: np.float32(output_max)}, ) hardtanh_op.AddScalarParam( OpReluMinMax.param_min_value, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, {QCOM_DATA: np.float32(output_min)}, ) diff --git a/backends/qualcomm/builders/op_index.py b/backends/qualcomm/builders/op_index.py index 2a7da815265..997dad4cc6f 100644 --- a/backends/qualcomm/builders/op_index.py +++ b/backends/qualcomm/builders/op_index.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -51,7 +51,7 @@ def define_node( indices_node, node, indices_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -62,12 +62,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) gather_output_tensors = [output_tensor_wrapper] - gather_op = PyQnnWrapper.PyQnnOpWrapper( + gather_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpGather.op_name, @@ -78,7 +78,7 @@ def define_node( # If support tuple of tensor, need to refine it based on len gather_op.AddScalarParam( OpGather.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_INT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_INT_32, {QCOM_DATA: np.int32(axis)}, ) diff --git a/backends/qualcomm/builders/op_index_put.py b/backends/qualcomm/builders/op_index_put.py index 23481894f0d..84eb2368967 100644 --- a/backends/qualcomm/builders/op_index_put.py +++ b/backends/qualcomm/builders/op_index_put.py @@ -2,7 +2,7 @@ from collections import OrderedDict from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -34,8 +34,8 @@ def __init__(self, *args) -> None: def define_node( # noqa: C901 self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: op_wrapper_list = [] input_node = self.get_node(node.args[0]) # Because the args[0] of index_put op doesn't annotate, need to fill in the quant_attr with the node here. @@ -48,7 +48,7 @@ def define_node( # noqa: C901 input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -144,7 +144,7 @@ def define_node( # noqa: C901 range_index_node, node, range_indices, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) # store it for future concatenation @@ -178,7 +178,7 @@ def define_node( # noqa: C901 indices_node, node, indices_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) if indices_tensor.nelement() < max_indices_in_specified_index: @@ -188,16 +188,16 @@ def define_node( # noqa: C901 indices_multiples_shape = [len(indices_multiples)] indices_tile_tensor_wrapper = self.define_custom_tensor_wrapper( node_name=node.name + f"_indices_tile_{i}", - tensor_type=PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + tensor_type=PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, dtype=QNN_TENSOR_TYPE_MAP[indices_tensor.dtype], - quant_encoding=PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED, + quant_encoding=PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED, quant_configs={}, dims=indices_tensor.size(), tensor=indices_tensor, is_fake_tensor=True, nodes_to_wrappers=nodes_to_wrappers, ) - tile_op = PyQnnWrapper.PyQnnOpWrapper( + tile_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpTile.op_name, @@ -206,7 +206,7 @@ def define_node( # noqa: C901 tile_op.AddOutputTensors([indices_tile_tensor_wrapper]) tile_op.AddTensorParam( OpTile.param_multiples, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(indices_multiples_shape), indices_multiples_shape, np.array(indices_multiples, dtype=np.uint32), @@ -221,16 +221,16 @@ def define_node( # noqa: C901 reshape_output_tensor = indices_tensor.reshape(reshape_shape) reshape_output_tensor_wrapper = self.define_custom_tensor_wrapper( node_name=node.name + f"_reshape_{i}", - tensor_type=PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + tensor_type=PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, dtype=QNN_TENSOR_TYPE_MAP[reshape_output_tensor.dtype], - quant_encoding=PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED, + quant_encoding=PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED, quant_configs={}, dims=reshape_output_tensor.size(), tensor=reshape_output_tensor, is_fake_tensor=True, nodes_to_wrappers=nodes_to_wrappers, ) - reshape_op = PyQnnWrapper.PyQnnOpWrapper( + reshape_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReshape.op_name, @@ -255,16 +255,16 @@ def define_node( # noqa: C901 multiples_shape = [len(multiples)] tile_output_tensor_wrapper = self.define_custom_tensor_wrapper( node_name=node.name + f"_tile_{i}", - tensor_type=PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + tensor_type=PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, dtype=QNN_TENSOR_TYPE_MAP[tile_output_tensor.dtype], - quant_encoding=PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED, + quant_encoding=PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED, quant_configs={}, dims=tile_output_tensor.size(), tensor=tile_output_tensor, is_fake_tensor=True, nodes_to_wrappers=nodes_to_wrappers, ) - tile_op = PyQnnWrapper.PyQnnOpWrapper( + tile_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpTile.op_name, @@ -273,7 +273,7 @@ def define_node( # noqa: C901 tile_op.AddOutputTensors([tile_output_tensor_wrapper]) tile_op.AddTensorParam( OpTile.param_multiples, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(multiples_shape), multiples_shape, np.array(multiples, dtype=np.uint32), @@ -299,16 +299,16 @@ def define_node( # noqa: C901 concat_output_tensor = torch.concat(index_tensors, dim=-1) concat_output_tensor_wrapper = self.define_custom_tensor_wrapper( node_name=node.name + "_concat", - tensor_type=PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + tensor_type=PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, dtype=QNN_TENSOR_TYPE_MAP[concat_output_tensor.dtype], - quant_encoding=PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED, + quant_encoding=PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED, quant_configs={}, dims=concat_output_tensor.size(), tensor=concat_output_tensor, is_fake_tensor=True, nodes_to_wrappers=nodes_to_wrappers, ) - concat_op = PyQnnWrapper.PyQnnOpWrapper( + concat_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpConcat.op_name, @@ -317,7 +317,7 @@ def define_node( # noqa: C901 concat_op.AddOutputTensors([concat_output_tensor_wrapper]) concat_op.AddScalarParam( OpConcat.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(concat_output_tensor.dim() - 1)}, ) op_wrapper_list.append(concat_op) @@ -328,7 +328,7 @@ def define_node( # noqa: C901 value_node, node, value_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) # handle broadcast scenario @@ -345,7 +345,7 @@ def define_node( # noqa: C901 value_dtype = ( QNN_TENSOR_TYPE_MAP[value_tensor.dtype] if value_quant_encoding - == PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED + == PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED else QNN_QUANT_TYPE_MAP[ ( torch.uint16 @@ -357,7 +357,7 @@ def define_node( # noqa: C901 value_reshape_tensor = value_tensor.reshape(new_value_shape) value_reshape_tensor_wrapper = self.define_custom_tensor_wrapper( node_name=node.name + "_value_reshape", - tensor_type=PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + tensor_type=PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, dtype=value_dtype, quant_encoding=value_quant_encoding, quant_configs=value_quant_configs, @@ -366,7 +366,7 @@ def define_node( # noqa: C901 is_fake_tensor=True, nodes_to_wrappers=nodes_to_wrappers, ) - value_reshape_op = PyQnnWrapper.PyQnnOpWrapper( + value_reshape_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReshape.op_name, @@ -394,7 +394,7 @@ def define_node( # noqa: C901 value_multiples_shape = [len(value_multiples)] value_tile_tensor_wrapper = self.define_custom_tensor_wrapper( node_name=node.name + "_value_tile", - tensor_type=PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + tensor_type=PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, dtype=value_dtype, quant_encoding=value_quant_encoding, quant_configs=value_quant_configs, @@ -403,7 +403,7 @@ def define_node( # noqa: C901 is_fake_tensor=True, nodes_to_wrappers=nodes_to_wrappers, ) - value_tile_op = PyQnnWrapper.PyQnnOpWrapper( + value_tile_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpTile.op_name, @@ -412,7 +412,7 @@ def define_node( # noqa: C901 value_tile_op.AddOutputTensors([value_tile_tensor_wrapper]) value_tile_op.AddTensorParam( OpTile.param_multiples, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(value_multiples_shape), value_multiples_shape, np.array(value_multiples, dtype=np.uint32), @@ -425,11 +425,11 @@ def define_node( # noqa: C901 node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - index_put_op = PyQnnWrapper.PyQnnOpWrapper( + index_put_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpScatterNd.op_name, @@ -438,7 +438,7 @@ def define_node( # noqa: C901 if len(node.args) > 3 and node.args[3]: index_put_op.AddScalarParam( OpScatterNd.param_reduction, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: 1}, ) @@ -451,16 +451,16 @@ def define_node( # noqa: C901 target_index_reshape_tensor = index_input_tensor.reshape((*target_index, -1)) target_index_reshape_tensor_wrapper = self.define_custom_tensor_wrapper( node_name=node.name + "_target_index_reshape", - tensor_type=PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + tensor_type=PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, dtype=QNN_TENSOR_TYPE_MAP[target_index_reshape_tensor.dtype], - quant_encoding=PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED, + quant_encoding=PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_UNDEFINED, quant_configs={}, dims=target_index_reshape_tensor.size(), tensor=target_index_reshape_tensor, is_fake_tensor=True, nodes_to_wrappers=nodes_to_wrappers, ) - target_index_reshape_op = PyQnnWrapper.PyQnnOpWrapper( + target_index_reshape_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReshape.op_name, diff --git a/backends/qualcomm/builders/op_index_select.py b/backends/qualcomm/builders/op_index_select.py index 22733e45397..56d5963e5e9 100644 --- a/backends/qualcomm/builders/op_index_select.py +++ b/backends/qualcomm/builders/op_index_select.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -26,15 +26,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -47,7 +47,7 @@ def define_node( indices_node, node, indices_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -58,12 +58,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) gather_output_tensors = [output_tensor_wrapper] - gather_op = PyQnnWrapper.PyQnnOpWrapper( + gather_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpGather.op_name, @@ -74,7 +74,7 @@ def define_node( # If support tuple of tensor, need to refine it based on len gather_op.AddScalarParam( OpGather.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_INT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_INT_32, {QCOM_DATA: np.int32(axis)}, ) diff --git a/backends/qualcomm/builders/op_instance_norm.py b/backends/qualcomm/builders/op_instance_norm.py index 08c4730ce1d..45a863d140a 100644 --- a/backends/qualcomm/builders/op_instance_norm.py +++ b/backends/qualcomm/builders/op_instance_norm.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from executorch.backends.qualcomm.utils.constants import ( @@ -34,8 +34,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) weight_node = self.get_node(node.args[1]) bias_node = self.get_node(node.args[2]) @@ -44,7 +44,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) input_tensor_wrappers = [input_tensor_wrapper] @@ -54,7 +54,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) output_tensor_wrappers = [output_tensor_wrapper] @@ -85,7 +85,7 @@ def define_node( weight_node, node, weight_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) input_tensor_wrappers.append(weight_tensor_wrapper) @@ -96,12 +96,12 @@ def define_node( bias_node, node, bias_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) input_tensor_wrappers.append(bias_tensor_wrapper) - instance_norm_op = PyQnnWrapper.PyQnnOpWrapper( + instance_norm_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpInstanceNorm.op_name, diff --git a/backends/qualcomm/builders/op_layer_norm.py b/backends/qualcomm/builders/op_layer_norm.py index 7c17980a82e..a51056eb7bb 100644 --- a/backends/qualcomm/builders/op_layer_norm.py +++ b/backends/qualcomm/builders/op_layer_norm.py @@ -7,7 +7,7 @@ import warnings from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -29,15 +29,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -60,7 +60,7 @@ def define_node( weight_node, node, weight_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) @@ -73,7 +73,7 @@ def define_node( bias_node, node, bias_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) layer_norm_input_tensors.append(bias_tensor_wrapper) @@ -85,11 +85,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - layer_norm_op = PyQnnWrapper.PyQnnOpWrapper( + layer_norm_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpLayerNorm.op_name, @@ -98,12 +98,12 @@ def define_node( layer_norm_op.AddOutputTensors([output_tensor_wrapper]) layer_norm_op.AddScalarParam( OpLayerNorm.param_epsilon, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, {QCOM_DATA: np.float32(epsilon)}, ) layer_norm_op.AddTensorParam( OpLayerNorm.param_axes, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(axis_shape), axis_shape, np.array(axis, dtype=np.uint32), diff --git a/backends/qualcomm/builders/op_le.py b/backends/qualcomm/builders/op_le.py index ad6a78b3da8..c58edc8e5c3 100644 --- a/backends/qualcomm/builders/op_le.py +++ b/backends/qualcomm/builders/op_le.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -51,7 +51,7 @@ def define_node( ) input_tensors.append(input_tensor_wrapper) - le_op = PyQnnWrapper.PyQnnOpWrapper( + le_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseLessEqual.op_name, diff --git a/backends/qualcomm/builders/op_linear.py b/backends/qualcomm/builders/op_linear.py index d5ac153b8d1..ed4c0e506f0 100644 --- a/backends/qualcomm/builders/op_linear.py +++ b/backends/qualcomm/builders/op_linear.py @@ -6,7 +6,7 @@ from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from executorch.backends.qualcomm.utils.constants import ( @@ -31,8 +31,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: linear_input_tensors = [] input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -40,7 +40,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) linear_input_tensors.append(input_tensor_wrapper) @@ -61,7 +61,7 @@ def define_node( weight_node, node, weight_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) linear_input_tensors.append(weight_tensor_wrapper) @@ -69,11 +69,11 @@ def define_node( if len(node.args) >= 3: bias_node = self.get_node(node.args[2]) - bias_tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC + bias_tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC bias_tensor = get_parameter(bias_node, self.edge_program) # if bias_node is getitem if bias_tensor is None: - bias_tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + bias_tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE bias_tensor = bias_node.meta["val"] bias_tensor_wrapper = self.define_tensor( @@ -90,11 +90,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - linear_op = PyQnnWrapper.PyQnnOpWrapper( + linear_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpFullyConnected.op_name, diff --git a/backends/qualcomm/builders/op_log.py b/backends/qualcomm/builders/op_log.py index 397e2072489..8d8d4e64a98 100644 --- a/backends/qualcomm/builders/op_log.py +++ b/backends/qualcomm/builders/op_log.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,15 +24,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) log_inp_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) log_input_tensors = [log_inp_tensor_wrapper] @@ -42,12 +42,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) log_output_tensors = [output_tensor_wrapper] - log_op = PyQnnWrapper.PyQnnOpWrapper( + log_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseLog.op_name, diff --git a/backends/qualcomm/builders/op_log_softmax.py b/backends/qualcomm/builders/op_log_softmax.py index 947140006a3..73dddb684e0 100644 --- a/backends/qualcomm/builders/op_log_softmax.py +++ b/backends/qualcomm/builders/op_log_softmax.py @@ -6,7 +6,7 @@ import warnings from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch from executorch.backends.qualcomm.utils.constants import QCOM_AXIS_ORDER, QCOM_DATA @@ -26,8 +26,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -35,7 +35,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) log_softmax_input_tensors = [log_softmax_inp_tensor_wrapper] @@ -45,7 +45,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) log_softmax_output_tensors = [log_softmax_output_tensor_wrapper] @@ -65,7 +65,7 @@ def define_node( ) return None - log_softmax_op = PyQnnWrapper.PyQnnOpWrapper( + log_softmax_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpLogSoftmax.op_name, @@ -75,7 +75,7 @@ def define_node( log_softmax_op.AddScalarParam( OpLogSoftmax.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(dim)}, ) return log_softmax_op diff --git a/backends/qualcomm/builders/op_logical_not.py b/backends/qualcomm/builders/op_logical_not.py index 4e8fc8543a7..fc639b21ef5 100644 --- a/backends/qualcomm/builders/op_logical_not.py +++ b/backends/qualcomm/builders/op_logical_not.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,15 +24,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -41,11 +41,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - logical_not_op = PyQnnWrapper.PyQnnOpWrapper( + logical_not_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseNot.op_name, diff --git a/backends/qualcomm/builders/op_lt.py b/backends/qualcomm/builders/op_lt.py index 2558a97dfab..aeb9b8a1eaa 100644 --- a/backends/qualcomm/builders/op_lt.py +++ b/backends/qualcomm/builders/op_lt.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -51,7 +51,7 @@ def define_node( ) input_tensors.append(input_tensor_wrapper) - lt_op = PyQnnWrapper.PyQnnOpWrapper( + lt_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseLess.op_name, diff --git a/backends/qualcomm/builders/op_matmul.py b/backends/qualcomm/builders/op_matmul.py index 5a1e366f384..bc3bddfcd69 100644 --- a/backends/qualcomm/builders/op_matmul.py +++ b/backends/qualcomm/builders/op_matmul.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,8 +24,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: matmul_input_tensors = [] for index in range(2): input_node = self.get_node(node.args[index]) @@ -35,7 +35,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) matmul_input_tensors.append(input_tensor_wrapper) @@ -45,12 +45,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) matmul_output_tensors = [output_tensor_wrapper] - matmul_op = PyQnnWrapper.PyQnnOpWrapper( + matmul_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpMatMul.op_name ) matmul_op.AddInputTensors(matmul_input_tensors) diff --git a/backends/qualcomm/builders/op_max.py b/backends/qualcomm/builders/op_max.py index 8406973ab5a..92d58b7f2b8 100644 --- a/backends/qualcomm/builders/op_max.py +++ b/backends/qualcomm/builders/op_max.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) min_output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -51,7 +51,7 @@ def define_node( ) min_input_tensors.append(input_tensor_wrapper) - max_op = PyQnnWrapper.PyQnnOpWrapper( + max_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseMaximum.op_name, diff --git a/backends/qualcomm/builders/op_max_dim.py b/backends/qualcomm/builders/op_max_dim.py index 354444da550..a00f04298af 100644 --- a/backends/qualcomm/builders/op_max_dim.py +++ b/backends/qualcomm/builders/op_max_dim.py @@ -6,7 +6,7 @@ from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> List[PyQnnWrapper.PyQnnOpWrapper]: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> List[PyQnnManager.PyQnnOpWrapper]: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -52,7 +52,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -62,7 +62,7 @@ def define_node( dims = [node.meta[QCOM_AXIS_ORDER].index(max_dim) for max_dim in dims] dims_shape = [len(dims)] - reduce_max_op = PyQnnWrapper.PyQnnOpWrapper( + reduce_max_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReduceMax.op_name, @@ -72,7 +72,7 @@ def define_node( reduce_max_op.AddTensorParam( OpReduceMax.param_axes, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(dims_shape), dims_shape, np.array(dims, dtype=np.uint32), @@ -82,7 +82,7 @@ def define_node( keep_dims = cast(bool, node.args[2]) reduce_max_op.AddScalarParam( OpReduceMax.param_keep_dims, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: keep_dims}, ) diff --git a/backends/qualcomm/builders/op_max_pool2d.py b/backends/qualcomm/builders/op_max_pool2d.py index 5da1bd1ac0f..6091fb8d053 100644 --- a/backends/qualcomm/builders/op_max_pool2d.py +++ b/backends/qualcomm/builders/op_max_pool2d.py @@ -6,7 +6,7 @@ import warnings from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -55,7 +55,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) # kernel info @@ -94,7 +94,7 @@ def define_node( if ceil_mode: mode = OpPoolMax2d.RoundingMode.CEIL - max_pool2d_op = PyQnnWrapper.PyQnnOpWrapper( + max_pool2d_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpPoolMax2d.op_name, @@ -104,7 +104,7 @@ def define_node( max_pool2d_op.AddTensorParam( OpPoolMax2d.param_filter_size, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(filter_size_shape), filter_size_shape, np.array( @@ -115,7 +115,7 @@ def define_node( ) max_pool2d_op.AddTensorParam( OpPoolMax2d.param_stride, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(stride_shape), stride_shape, np.array( @@ -126,7 +126,7 @@ def define_node( ) max_pool2d_op.AddTensorParam( OpPoolMax2d.param_pad_amount, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(padding_shape), padding_shape, np.array( @@ -138,7 +138,7 @@ def define_node( max_pool2d_op.AddScalarParam( OpPoolMax2d.param_rounding_mode, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(mode)}, ) diff --git a/backends/qualcomm/builders/op_mean_dim.py b/backends/qualcomm/builders/op_mean_dim.py index 10644e17c79..45b91e529a0 100644 --- a/backends/qualcomm/builders/op_mean_dim.py +++ b/backends/qualcomm/builders/op_mean_dim.py @@ -6,7 +6,7 @@ from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -70,11 +70,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - reduce_mean_op = PyQnnWrapper.PyQnnOpWrapper( + reduce_mean_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReduceMean.op_name, @@ -83,7 +83,7 @@ def define_node( reduce_mean_op.AddOutputTensors([output_tensor_wrapper]) reduce_mean_op.AddTensorParam( OpReduceMean.param_axes, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(mean_dims_shape), mean_dims_shape, np.array(mean_dims, dtype=np.uint32), @@ -93,7 +93,7 @@ def define_node( keep_dims = cast(bool, node.args[2]) reduce_mean_op.AddScalarParam( OpReduceMean.param_keep_dims, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: keep_dims}, ) diff --git a/backends/qualcomm/builders/op_min.py b/backends/qualcomm/builders/op_min.py index 28c766cffb5..359ac0e6580 100644 --- a/backends/qualcomm/builders/op_min.py +++ b/backends/qualcomm/builders/op_min.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) min_output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -51,7 +51,7 @@ def define_node( ) min_input_tensors.append(input_tensor_wrapper) - min_op = PyQnnWrapper.PyQnnOpWrapper( + min_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseMinimum.op_name, diff --git a/backends/qualcomm/builders/op_min_dim.py b/backends/qualcomm/builders/op_min_dim.py index 6425a9aa755..63775847cdf 100644 --- a/backends/qualcomm/builders/op_min_dim.py +++ b/backends/qualcomm/builders/op_min_dim.py @@ -6,7 +6,7 @@ from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> List[PyQnnWrapper.PyQnnOpWrapper]: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> List[PyQnnManager.PyQnnOpWrapper]: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -52,7 +52,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -62,7 +62,7 @@ def define_node( dims = [node.meta[QCOM_AXIS_ORDER].index(min_dim) for min_dim in dims] dims_shape = [len(dims)] - reduce_min_op = PyQnnWrapper.PyQnnOpWrapper( + reduce_min_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReduceMin.op_name, @@ -72,7 +72,7 @@ def define_node( reduce_min_op.AddTensorParam( OpReduceMin.param_axes, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(dims_shape), dims_shape, np.array(dims, dtype=np.uint32), @@ -82,7 +82,7 @@ def define_node( keep_dims = cast(bool, node.args[2]) reduce_min_op.AddScalarParam( OpReduceMin.param_keep_dims, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: keep_dims}, ) diff --git a/backends/qualcomm/builders/op_mul.py b/backends/qualcomm/builders/op_mul.py index f003007e0df..655f0b8fecd 100644 --- a/backends/qualcomm/builders/op_mul.py +++ b/backends/qualcomm/builders/op_mul.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) mul_output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -51,7 +51,7 @@ def define_node( ) mul_input_tensors.append(input_tensor_wrapper) - mul_op = PyQnnWrapper.PyQnnOpWrapper( + mul_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseMultiply.op_name, diff --git a/backends/qualcomm/builders/op_ne.py b/backends/qualcomm/builders/op_ne.py index 660c78e3e14..9a8bfac83f1 100644 --- a/backends/qualcomm/builders/op_ne.py +++ b/backends/qualcomm/builders/op_ne.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -51,7 +51,7 @@ def define_node( ) input_tensors.append(input_tensor_wrapper) - ne_op = PyQnnWrapper.PyQnnOpWrapper( + ne_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseNotEqual.op_name, diff --git a/backends/qualcomm/builders/op_neg.py b/backends/qualcomm/builders/op_neg.py index 911fbe742c8..a1e7f904c20 100644 --- a/backends/qualcomm/builders/op_neg.py +++ b/backends/qualcomm/builders/op_neg.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from .node_visitor import NodeVisitor @@ -23,15 +23,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) neg_inp_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) neg_input_tensors = [neg_inp_tensor_wrapper] @@ -40,11 +40,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) neg_output_tensors = [output_tensor_wrapper] - neg_op = PyQnnWrapper.PyQnnOpWrapper( + neg_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseNeg.op_name, diff --git a/backends/qualcomm/builders/op_or.py b/backends/qualcomm/builders/op_or.py index c0a995d3631..b397cb795c1 100644 --- a/backends/qualcomm/builders/op_or.py +++ b/backends/qualcomm/builders/op_or.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) or_output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -50,7 +50,7 @@ def define_node( nodes_to_wrappers, ) or_input_tensors.append(input_tensor_wrapper) - or_op = PyQnnWrapper.PyQnnOpWrapper( + or_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseOr.op_name, diff --git a/backends/qualcomm/builders/op_pad.py b/backends/qualcomm/builders/op_pad.py index 7832e180ebb..2302d6d55a0 100644 --- a/backends/qualcomm/builders/op_pad.py +++ b/backends/qualcomm/builders/op_pad.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -26,15 +26,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) pad_inp_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) pad_input_tensors = [pad_inp_tensor_wrapper] @@ -44,7 +44,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) pad_output_tensors = [output_tensor_wrapper] @@ -64,7 +64,7 @@ def define_node( pad_amount = pad_amount[list(node.meta[QCOM_AXIS_ORDER])] pad_amount_val = node.args[2] - pad_op = PyQnnWrapper.PyQnnOpWrapper( + pad_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpPad.op_name, @@ -75,7 +75,7 @@ def define_node( # For now, we only support constant (0) padding due to torch implementation pad_op.AddScalarParam( OpPad.param_scheme, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(OpPad.Scheme.CONSTANT)}, ) @@ -87,7 +87,7 @@ def define_node( pad_op.AddTensorParam( OpPad.param_pad_amount, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(pad_amount_shape), pad_amount_shape, pad_amount, diff --git a/backends/qualcomm/builders/op_pow.py b/backends/qualcomm/builders/op_pow.py index 50568bfbcc1..395f732c46f 100644 --- a/backends/qualcomm/builders/op_pow.py +++ b/backends/qualcomm/builders/op_pow.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -25,14 +25,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) pow_output_tensors = [output_tensor_wrapper] @@ -41,7 +41,7 @@ def define_node( input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -58,13 +58,13 @@ def define_node( exp_node, node, exp_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) pow_input_tensors = [input_tensor_wrapper, exp_tensor_wrapper] - pow_op = PyQnnWrapper.PyQnnOpWrapper( + pow_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWisePower.op_name, diff --git a/backends/qualcomm/builders/op_prelu.py b/backends/qualcomm/builders/op_prelu.py index 5291acfbc8c..217fc77935d 100644 --- a/backends/qualcomm/builders/op_prelu.py +++ b/backends/qualcomm/builders/op_prelu.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from executorch.backends.qualcomm.utils.constants import QCOM_AXIS_ORDER @@ -25,15 +25,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) prelu_inp_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -55,7 +55,7 @@ def define_node( coeff_node, node, coeff_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) prelu_input_tensors = [prelu_inp_tensor_wrapper, coeff_tensor_wrapper] @@ -65,12 +65,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) prelu_output_tensors = [output_tensor_wrapper] - prelu_op = PyQnnWrapper.PyQnnOpWrapper( + prelu_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpPRelu.op_name, diff --git a/backends/qualcomm/builders/op_quantize.py b/backends/qualcomm/builders/op_quantize.py index 7d7bd3ec9ec..b3125390e8e 100644 --- a/backends/qualcomm/builders/op_quantize.py +++ b/backends/qualcomm/builders/op_quantize.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from executorch.backends.qualcomm.utils.constants import QCOM_ENCODING, QCOM_QUANT_ATTRS @@ -22,8 +22,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: quant_input_tensors = [] input_node = node.args[0] input_tensor = self.get_tensor(input_node, node) @@ -31,7 +31,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) quant_input_tensors.append(inp_tensor_wrapper) @@ -47,12 +47,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) quant_output_tensors = [output_tensor_wrapper] - quant_op = PyQnnWrapper.PyQnnOpWrapper( + quant_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpQuantize.op_name, diff --git a/backends/qualcomm/builders/op_relu.py b/backends/qualcomm/builders/op_relu.py index 94afce56113..140dc5f4df0 100644 --- a/backends/qualcomm/builders/op_relu.py +++ b/backends/qualcomm/builders/op_relu.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,15 +24,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) relu_inp_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) relu_input_tensors = [relu_inp_tensor_wrapper] @@ -42,12 +42,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) relu_output_tensors = [output_tensor_wrapper] - relu_op = PyQnnWrapper.PyQnnOpWrapper( + relu_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpRelu.op_name, diff --git a/backends/qualcomm/builders/op_repeat.py b/backends/qualcomm/builders/op_repeat.py index abd0cff73e8..0ebbc57bb5a 100644 --- a/backends/qualcomm/builders/op_repeat.py +++ b/backends/qualcomm/builders/op_repeat.py @@ -6,7 +6,7 @@ from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -26,15 +26,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -43,14 +43,14 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) multiples = cast(List[int], node.args[1]) multiples_shape = [len(multiples)] - tile_op = PyQnnWrapper.PyQnnOpWrapper( + tile_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpTile.op_name, @@ -59,7 +59,7 @@ def define_node( tile_op.AddOutputTensors([output_tensor_wrapper]) tile_op.AddTensorParam( OpTile.param_multiples, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(multiples_shape), multiples_shape, np.array(multiples, dtype=np.uint32), diff --git a/backends/qualcomm/builders/op_reshape.py b/backends/qualcomm/builders/op_reshape.py index 6cc7d81af33..a4f8e1eb554 100644 --- a/backends/qualcomm/builders/op_reshape.py +++ b/backends/qualcomm/builders/op_reshape.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,15 +24,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -40,11 +40,11 @@ def define_node( node, node, node.meta["val"], - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - reshape_op = PyQnnWrapper.PyQnnOpWrapper( + reshape_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReshape.op_name, diff --git a/backends/qualcomm/builders/op_resize.py b/backends/qualcomm/builders/op_resize.py index 04216ce9d2c..13a08ea98e0 100644 --- a/backends/qualcomm/builders/op_resize.py +++ b/backends/qualcomm/builders/op_resize.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) align_corners = cast(bool, node.args[2]) @@ -49,10 +49,10 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - resize_op = PyQnnWrapper.PyQnnOpWrapper( + resize_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpResize.op_name, @@ -62,23 +62,23 @@ def define_node( resize_op.AddScalarParam( OpResize.param_exclude_outside, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: False}, ) resize_op.AddScalarParam( OpResize.param_transformation_mode, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: transformation_mode}, ) resize_op.AddScalarParam( OpResize.param_interpolation_mode, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: interpolation_mode}, ) resize_op.AddScalarParam( OpResize.param_cubic_coeff, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, {QCOM_DATA: cubic_coeff}, ) diff --git a/backends/qualcomm/builders/op_rms_norm.py b/backends/qualcomm/builders/op_rms_norm.py index 6d5060f730b..2993d268d20 100644 --- a/backends/qualcomm/builders/op_rms_norm.py +++ b/backends/qualcomm/builders/op_rms_norm.py @@ -7,7 +7,7 @@ import warnings from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -34,8 +34,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: # args of node : ['input', 'normalized_shape', 'weight', 'eps'] input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -43,7 +43,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -67,7 +67,7 @@ def define_node( weight_node, node, weight_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) @@ -89,7 +89,7 @@ def define_node( bias_node, node, bias_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) @@ -99,11 +99,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - rms_nrom_op = PyQnnWrapper.PyQnnOpWrapper( + rms_nrom_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpRmsNorm.op_name, @@ -115,12 +115,12 @@ def define_node( rms_nrom_op.AddOutputTensors([output_tensor_wrapper]) rms_nrom_op.AddScalarParam( OpRmsNorm.param_epsilon, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_FLOAT_32, {QCOM_DATA: np.float32(epsilon)}, ) rms_nrom_op.AddTensorParam( OpRmsNorm.param_axes, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(axes_shape), axes_shape, np.array(axes, dtype=np.uint32), diff --git a/backends/qualcomm/builders/op_round.py b/backends/qualcomm/builders/op_round.py index 08aa83b5811..c458375588a 100644 --- a/backends/qualcomm/builders/op_round.py +++ b/backends/qualcomm/builders/op_round.py @@ -1,7 +1,7 @@ import warnings from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from .node_visitor import NodeVisitor @@ -20,15 +20,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -44,11 +44,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - round_op = PyQnnWrapper.PyQnnOpWrapper( + round_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseRound.op_name, diff --git a/backends/qualcomm/builders/op_rsqrt.py b/backends/qualcomm/builders/op_rsqrt.py index 0f0a069441d..28cd191c8d5 100644 --- a/backends/qualcomm/builders/op_rsqrt.py +++ b/backends/qualcomm/builders/op_rsqrt.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,15 +24,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) rsqrt_inp_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) rsqrt_input_tensors = [rsqrt_inp_tensor_wrapper] @@ -42,12 +42,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) rsqrt_output_tensors = [output_tensor_wrapper] - rsqrt_op = PyQnnWrapper.PyQnnOpWrapper( + rsqrt_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseRsqrt.op_name, diff --git a/backends/qualcomm/builders/op_scalar_tensor.py b/backends/qualcomm/builders/op_scalar_tensor.py index bb6b5825803..69daf23f38f 100644 --- a/backends/qualcomm/builders/op_scalar_tensor.py +++ b/backends/qualcomm/builders/op_scalar_tensor.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -23,8 +23,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: val = node.args[0] out_tensor = torch.tensor([val], dtype=node.meta["val"].dtype) @@ -46,6 +46,6 @@ def define_node( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) diff --git a/backends/qualcomm/builders/op_select_copy.py b/backends/qualcomm/builders/op_select_copy.py index 69d237c282d..f004fed8a67 100644 --- a/backends/qualcomm/builders/op_select_copy.py +++ b/backends/qualcomm/builders/op_select_copy.py @@ -6,7 +6,7 @@ import math from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -44,7 +44,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -63,7 +63,7 @@ def define_node( range_shape = [input_tensor_rank, 3] - stride_slice_op = PyQnnWrapper.PyQnnOpWrapper( + stride_slice_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpStridedSlice.op_name, @@ -73,7 +73,7 @@ def define_node( stride_slice_op.AddTensorParam( OpStridedSlice.param_ranges, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_INT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_INT_32, len(range_shape), range_shape, np.array(ranges, dtype=np.int32), @@ -82,7 +82,7 @@ def define_node( stride_slice_op.AddScalarParam( OpStridedSlice.param_shrink_axes, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(math.pow(2, dim))}, ) diff --git a/backends/qualcomm/builders/op_sigmoid.py b/backends/qualcomm/builders/op_sigmoid.py index 20f933ed128..f374ebbc996 100644 --- a/backends/qualcomm/builders/op_sigmoid.py +++ b/backends/qualcomm/builders/op_sigmoid.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,15 +24,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) sigmoid_inp_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) sigmoid_input_tensors = [sigmoid_inp_tensor_wrapper] @@ -42,12 +42,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) sigmoid_output_tensors = [output_tensor_wrapper] - sigmoid_op = PyQnnWrapper.PyQnnOpWrapper( + sigmoid_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpSigmoid.op_name, diff --git a/backends/qualcomm/builders/op_sign.py b/backends/qualcomm/builders/op_sign.py index faf2f2e0066..2a77a3e9d82 100644 --- a/backends/qualcomm/builders/op_sign.py +++ b/backends/qualcomm/builders/op_sign.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,15 +24,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -41,11 +41,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - sign_op = PyQnnWrapper.PyQnnOpWrapper( + sign_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseSign.op_name, diff --git a/backends/qualcomm/builders/op_sin.py b/backends/qualcomm/builders/op_sin.py index 5c389ca3b20..5099cabd23c 100644 --- a/backends/qualcomm/builders/op_sin.py +++ b/backends/qualcomm/builders/op_sin.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,15 +24,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -41,11 +41,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - sin_op = PyQnnWrapper.PyQnnOpWrapper( + sin_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseSin.op_name, diff --git a/backends/qualcomm/builders/op_skip_ops.py b/backends/qualcomm/builders/op_skip_ops.py index f52f69d6019..2a60b320927 100644 --- a/backends/qualcomm/builders/op_skip_ops.py +++ b/backends/qualcomm/builders/op_skip_ops.py @@ -6,7 +6,7 @@ from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -25,7 +25,7 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], ) -> None: return @@ -41,14 +41,14 @@ class OpGetItem(OpSkipOps): def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], ) -> None: if isinstance(node.args[1], tuple) or isinstance(node.args[1], list): raise AssertionError( f"Invalid number of index for {node.name }: {len(node.args[1])}" ) idx = node.args[1] - # to fit the format of nodes_to_wrappers, Dict[str, Dict[int, PyQnnWrapper.TensorWrapper]], + # to fit the format of nodes_to_wrappers, Dict[str, Dict[int, PyQnnManager.TensorWrapper]], nodes_to_wrappers[node.name] = { 0: nodes_to_wrappers.get(node.args[0].name).get(idx) } diff --git a/backends/qualcomm/builders/op_slice_copy.py b/backends/qualcomm/builders/op_slice_copy.py index 5923d438252..8dcf7365361 100644 --- a/backends/qualcomm/builders/op_slice_copy.py +++ b/backends/qualcomm/builders/op_slice_copy.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch from executorch.backends.qualcomm.utils.constants import QCOM_AXIS_ORDER @@ -25,11 +25,11 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -44,7 +44,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) dim = cast(int, node.args[1]) @@ -75,7 +75,7 @@ def define_node( range_shape = [input_tensor_rank, 3] - stride_slice_op = PyQnnWrapper.PyQnnOpWrapper( + stride_slice_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpStridedSlice.op_name, @@ -85,7 +85,7 @@ def define_node( stride_slice_op.AddTensorParam( OpStridedSlice.param_ranges, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_INT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_INT_32, len(range_shape), range_shape, np.array(ranges, dtype=np.int32), diff --git a/backends/qualcomm/builders/op_slice_scatter.py b/backends/qualcomm/builders/op_slice_scatter.py index 9fa162d6653..da9e810d064 100644 --- a/backends/qualcomm/builders/op_slice_scatter.py +++ b/backends/qualcomm/builders/op_slice_scatter.py @@ -1,6 +1,6 @@ from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from executorch.exir.dialects._ops import ops as exir_ops @@ -20,15 +20,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -38,7 +38,7 @@ def define_node( value_node, node, value_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -47,7 +47,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) dim = cast(int, node.args[2]) if len(node.args) > 2 else 0 @@ -101,11 +101,11 @@ def define_node( target_index_node, node, target_index_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) - slice_scatter_op = PyQnnWrapper.PyQnnOpWrapper( + slice_scatter_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpScatterNd.op_name, diff --git a/backends/qualcomm/builders/op_softmax.py b/backends/qualcomm/builders/op_softmax.py index 556f5701f54..356c240fc72 100644 --- a/backends/qualcomm/builders/op_softmax.py +++ b/backends/qualcomm/builders/op_softmax.py @@ -6,7 +6,7 @@ import warnings from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch from executorch.backends.qualcomm.utils.constants import QCOM_AXIS_ORDER, QCOM_DATA @@ -26,15 +26,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) softmax_inp_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) softmax_input_tensors = [softmax_inp_tensor_wrapper] @@ -44,7 +44,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) softmax_output_tensors = [output_tensor_wrapper] @@ -62,7 +62,7 @@ def define_node( ) return None - softmax_op = PyQnnWrapper.PyQnnOpWrapper( + softmax_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpSoftmax.op_name, @@ -72,7 +72,7 @@ def define_node( softmax_op.AddScalarParam( OpSoftmax.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(dim)}, ) diff --git a/backends/qualcomm/builders/op_space_to_depth.py b/backends/qualcomm/builders/op_space_to_depth.py index 74e31df475f..b16fa85bbac 100644 --- a/backends/qualcomm/builders/op_space_to_depth.py +++ b/backends/qualcomm/builders/op_space_to_depth.py @@ -6,7 +6,7 @@ from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,15 +27,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -44,7 +44,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -54,7 +54,7 @@ def define_node( block_size = np.array(block_size, dtype=np.uint32) block_size_shape = [2] - space_to_depth_op = PyQnnWrapper.PyQnnOpWrapper( + space_to_depth_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpSpaceToDepth.op_name, @@ -63,7 +63,7 @@ def define_node( space_to_depth_op.AddOutputTensors([output_tensor_wrapper]) space_to_depth_op.AddTensorParam( OpSpaceToDepth.param_block_size, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(block_size.shape), block_size_shape, block_size, @@ -71,7 +71,7 @@ def define_node( ) space_to_depth_op.AddScalarParam( OpSpaceToDepth.param_mode, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(OpSpaceToDepth.Mode.CRD)}, ) diff --git a/backends/qualcomm/builders/op_split_with_sizes.py b/backends/qualcomm/builders/op_split_with_sizes.py index fc5ba0f11fb..bbac10862c0 100644 --- a/backends/qualcomm/builders/op_split_with_sizes.py +++ b/backends/qualcomm/builders/op_split_with_sizes.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -26,8 +26,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -36,7 +36,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) input_tensor_wrappers = [input_tensor_wrapper] @@ -49,7 +49,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, wrapper_idx=index, ) @@ -75,7 +75,7 @@ def define_node( if QCOM_AXIS_ORDER in node.meta: dim = node.meta[QCOM_AXIS_ORDER].index(dim) - split_op = PyQnnWrapper.PyQnnOpWrapper( + split_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpSplit.op_name, @@ -84,7 +84,7 @@ def define_node( split_op.AddOutputTensors(output_tensor_wrappers) split_op.AddTensorParam( OpSplit.param_split_index, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(split_indices_shape), split_indices_shape, np.array(split_indices, dtype=np.uint32), @@ -93,7 +93,7 @@ def define_node( split_op.AddScalarParam( OpSplit.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(dim)}, ) return split_op diff --git a/backends/qualcomm/builders/op_sqrt.py b/backends/qualcomm/builders/op_sqrt.py index b71d4d68c30..d4bfe724853 100644 --- a/backends/qualcomm/builders/op_sqrt.py +++ b/backends/qualcomm/builders/op_sqrt.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,8 +24,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: # tensor input input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -34,7 +34,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) sqrt_input_tensors = [input_tensor_wrapper] @@ -44,12 +44,12 @@ def define_node( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) sqrt_output_tensors = [output_tensor_wrapper] - sqrt_op = PyQnnWrapper.PyQnnOpWrapper( + sqrt_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseSquareRoot.op_name, diff --git a/backends/qualcomm/builders/op_squeeze.py b/backends/qualcomm/builders/op_squeeze.py index 0cb7bf142b9..24b2d194dd7 100644 --- a/backends/qualcomm/builders/op_squeeze.py +++ b/backends/qualcomm/builders/op_squeeze.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,8 +24,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -33,7 +33,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -42,11 +42,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - squeeze_op = PyQnnWrapper.PyQnnOpWrapper( + squeeze_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReshape.op_name, diff --git a/backends/qualcomm/builders/op_stack.py b/backends/qualcomm/builders/op_stack.py index 2d8587d51cd..6b27d7f5e4c 100644 --- a/backends/qualcomm/builders/op_stack.py +++ b/backends/qualcomm/builders/op_stack.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -26,8 +26,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node_list = node.args[0] stack_input_tensors = [] for input_node in input_node_list: @@ -36,7 +36,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) stack_input_tensors.append(stack_inp_tensor_wrapper) @@ -45,7 +45,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) stack_output_tensors = [output_tensor_wrapper] @@ -55,7 +55,7 @@ def define_node( dim = dim % len(output_tensor.shape) if QCOM_AXIS_ORDER in node.meta: dim = node.meta[QCOM_AXIS_ORDER].index(dim) - stack_op = PyQnnWrapper.PyQnnOpWrapper( + stack_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpPack.op_name, @@ -65,7 +65,7 @@ def define_node( stack_op.AddScalarParam( OpPack.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(dim)}, ) diff --git a/backends/qualcomm/builders/op_sub.py b/backends/qualcomm/builders/op_sub.py index 064d9b3cd42..9d70be6cc59 100644 --- a/backends/qualcomm/builders/op_sub.py +++ b/backends/qualcomm/builders/op_sub.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) sub_output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -51,7 +51,7 @@ def define_node( ) sub_input_tensors.append(input_tensor_wrapper) - sub_op = PyQnnWrapper.PyQnnOpWrapper( + sub_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseSubtract.op_name, diff --git a/backends/qualcomm/builders/op_sum_int_list.py b/backends/qualcomm/builders/op_sum_int_list.py index af5fd1cecba..8b686261b97 100644 --- a/backends/qualcomm/builders/op_sum_int_list.py +++ b/backends/qualcomm/builders/op_sum_int_list.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -26,8 +26,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -35,7 +35,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) sum_input_tensors = [input_tensor_wrapper] @@ -54,11 +54,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) sum_output_tensors = [output_tensor_wrapper] - sum_op = PyQnnWrapper.PyQnnOpWrapper( + sum_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReduceSum.op_name, @@ -67,7 +67,7 @@ def define_node( sum_op.AddOutputTensors(sum_output_tensors) sum_op.AddTensorParam( OpReduceSum.param_axes, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(sum_dims_shape), sum_dims_shape, np.array(sum_dims, dtype=np.uint32), @@ -78,7 +78,7 @@ def define_node( keep_dims = cast(bool, node.args[2]) sum_op.AddScalarParam( OpReduceSum.param_keep_dims, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: keep_dims}, ) return sum_op diff --git a/backends/qualcomm/builders/op_tanh.py b/backends/qualcomm/builders/op_tanh.py index c61439398e3..fc95aec8335 100644 --- a/backends/qualcomm/builders/op_tanh.py +++ b/backends/qualcomm/builders/op_tanh.py @@ -6,7 +6,7 @@ from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -25,15 +25,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -42,11 +42,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - tanh_op = PyQnnWrapper.PyQnnOpWrapper( + tanh_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpTanh.op_name, diff --git a/backends/qualcomm/builders/op_to.py b/backends/qualcomm/builders/op_to.py index 6774b0e3af6..9b024307934 100644 --- a/backends/qualcomm/builders/op_to.py +++ b/backends/qualcomm/builders/op_to.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from executorch.backends.qualcomm.utils.constants import QCOM_QUANT_ATTRS @@ -22,12 +22,12 @@ class To(NodeVisitor): sufixed_16_offset_diff = 32768 epsilon = 1e-6 sufixed_8 = { - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_SFIXED_POINT_8, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UFIXED_POINT_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_SFIXED_POINT_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UFIXED_POINT_8, } sufixed_16 = { - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_SFIXED_POINT_16, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UFIXED_POINT_16, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_SFIXED_POINT_16, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UFIXED_POINT_16, } def __init__(self, *args) -> None: @@ -79,8 +79,8 @@ def is_cast_node(self, node): def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -88,7 +88,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) node_input_tensors = [input_tensor_wrapper] @@ -110,7 +110,7 @@ def define_node( ) cast_intermediate_tensor_wrapper = self.define_custom_tensor_wrapper( node_name=node.name + "_cast", - tensor_type=PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + tensor_type=PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, dtype=QNN_TENSOR_TYPE_MAP[torch.int32], quant_encoding=input_quant_encoding, quant_configs=input_quant_configs, @@ -119,7 +119,7 @@ def define_node( is_fake_tensor=True, nodes_to_wrappers=nodes_to_wrappers, ) - cast_op = PyQnnWrapper.PyQnnOpWrapper( + cast_op = PyQnnManager.PyQnnOpWrapper( f"{node.name}_cast", QNN_OP_PACKAGE_NAME_QTI_AISW, OpCast.op_name, @@ -134,12 +134,12 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) qnn_op = OpCast if self.is_cast_node(node) else OpConvert - op = PyQnnWrapper.PyQnnOpWrapper( + op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, qnn_op.op_name ) op.AddInputTensors(node_input_tensors) diff --git a/backends/qualcomm/builders/op_topk.py b/backends/qualcomm/builders/op_topk.py index f310752c8f6..d027702ddf0 100644 --- a/backends/qualcomm/builders/op_topk.py +++ b/backends/qualcomm/builders/op_topk.py @@ -6,7 +6,7 @@ import warnings from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -31,8 +31,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -40,7 +40,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) @@ -70,7 +70,7 @@ def define_node( node, node, output_val_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -80,13 +80,13 @@ def define_node( node, node, output_idx_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, wrapper_idx=1, ) topk_output_tensors = [output_val_tensor_wrapper, output_index_tensor_wrapper] - topk_op = PyQnnWrapper.PyQnnOpWrapper( + topk_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpTopK.op_name, @@ -96,7 +96,7 @@ def define_node( topk_op.AddScalarParam( OpTopK.param_k, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(k)}, ) @@ -105,7 +105,7 @@ def define_node( largest = cast(bool, node.args[3]) topk_op.AddScalarParam( OpTopK.param_largest, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: largest}, ) diff --git a/backends/qualcomm/builders/op_transpose.py b/backends/qualcomm/builders/op_transpose.py index e7fd84e8e79..e3682c8bcde 100644 --- a/backends/qualcomm/builders/op_transpose.py +++ b/backends/qualcomm/builders/op_transpose.py @@ -6,7 +6,7 @@ from typing import cast, Dict, List -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -27,8 +27,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) permute_node = input_node if QCOM_INSERTED_PERMUTE in node.meta else node input_tensor = self.get_tensor(input_node, permute_node) @@ -36,7 +36,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -51,11 +51,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - transpose_op = PyQnnWrapper.PyQnnOpWrapper( + transpose_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpTranspose.op_name, @@ -67,7 +67,7 @@ def define_node( transpose_op.AddTensorParam( OpTranspose.param_perm, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, len(permute_order_shape), permute_order_shape, np.array(permute_order, dtype=np.uint32), diff --git a/backends/qualcomm/builders/op_unbind.py b/backends/qualcomm/builders/op_unbind.py index 7db8bf07596..66d05fcc636 100644 --- a/backends/qualcomm/builders/op_unbind.py +++ b/backends/qualcomm/builders/op_unbind.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import cast, Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import numpy as np import torch @@ -26,15 +26,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC, nodes_to_wrappers, ) unbind_input_tensors = [input_tensor_wrapper] @@ -46,7 +46,7 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, wrapper_idx=i, ) @@ -57,7 +57,7 @@ def define_node( dim = dim % len(input_tensor.shape) if QCOM_AXIS_ORDER in node.meta: dim = node.meta[QCOM_AXIS_ORDER].index(dim) - unbind_op = PyQnnWrapper.PyQnnOpWrapper( + unbind_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpUnpack.op_name, @@ -67,7 +67,7 @@ def define_node( unbind_op.AddScalarParam( OpUnpack.param_axis, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_UINT_32, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_UINT_32, {QCOM_DATA: np.uint32(dim)}, ) diff --git a/backends/qualcomm/builders/op_unsqueeze.py b/backends/qualcomm/builders/op_unsqueeze.py index 3408f3ec14f..46b7a904137 100644 --- a/backends/qualcomm/builders/op_unsqueeze.py +++ b/backends/qualcomm/builders/op_unsqueeze.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,8 +24,8 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) @@ -33,7 +33,7 @@ def define_node( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -42,11 +42,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - unsqueeze_op = PyQnnWrapper.PyQnnOpWrapper( + unsqueeze_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpReshape.op_name, diff --git a/backends/qualcomm/builders/op_upsample_bilinear2d.py b/backends/qualcomm/builders/op_upsample_bilinear2d.py index 7394823899e..fb9b4b078fd 100644 --- a/backends/qualcomm/builders/op_upsample_bilinear2d.py +++ b/backends/qualcomm/builders/op_upsample_bilinear2d.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from executorch.backends.qualcomm.utils.constants import QCOM_DATA @@ -25,15 +25,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -42,11 +42,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - resize_bilinear_op = PyQnnWrapper.PyQnnOpWrapper( + resize_bilinear_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpResizeBilinear.op_name, @@ -56,12 +56,12 @@ def define_node( resize_bilinear_op.AddScalarParam( OpResizeBilinear.param_align_corners, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: node.args[2]}, ) resize_bilinear_op.AddScalarParam( OpResizeBilinear.param_half_pixel_centers, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: not node.args[2]}, ) diff --git a/backends/qualcomm/builders/op_upsample_nearest2d.py b/backends/qualcomm/builders/op_upsample_nearest2d.py index a338f54b91f..8d85ba3576a 100644 --- a/backends/qualcomm/builders/op_upsample_nearest2d.py +++ b/backends/qualcomm/builders/op_upsample_nearest2d.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch from executorch.backends.qualcomm.utils.constants import QCOM_DATA @@ -25,15 +25,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: input_node = self.get_node(node.args[0]) input_tensor = self.get_tensor(input_node, node) input_tensor_wrapper = self.define_tensor( input_node, node, input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -42,11 +42,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - resize_nearest_op = PyQnnWrapper.PyQnnOpWrapper( + resize_nearest_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpResizeNearestNeighbor.op_name, @@ -56,12 +56,12 @@ def define_node( # align_corners is guaranteed to be false resize_nearest_op.AddScalarParam( OpResizeNearestNeighbor.param_align_corners, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: False}, ) resize_nearest_op.AddScalarParam( OpResizeNearestNeighbor.param_half_pixel_centers, - PyQnnWrapper.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, + PyQnnManager.Qnn_DataType_t.QNN_DATATYPE_BOOL_8, {QCOM_DATA: True}, ) diff --git a/backends/qualcomm/builders/op_where.py b/backends/qualcomm/builders/op_where.py index 460431a4814..6a9c750ee5e 100644 --- a/backends/qualcomm/builders/op_where.py +++ b/backends/qualcomm/builders/op_where.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,15 +24,15 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: conditional_input_node = self.get_node(node.args[0]) conditional_input_tensor = self.get_tensor(conditional_input_node, node) conditional_input_tensor_wrapper = self.define_tensor( conditional_input_node, node, conditional_input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -42,7 +42,7 @@ def define_node( true_input_node, node, true_input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -52,7 +52,7 @@ def define_node( false_input_node, node, false_input_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) @@ -61,11 +61,11 @@ def define_node( node, node, output_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) - where_op = PyQnnWrapper.PyQnnOpWrapper( + where_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseSelect.op_name, diff --git a/backends/qualcomm/builders/op_xor.py b/backends/qualcomm/builders/op_xor.py index d4462d9c707..eff5d1c009b 100644 --- a/backends/qualcomm/builders/op_xor.py +++ b/backends/qualcomm/builders/op_xor.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from typing import Dict -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import torch @@ -24,14 +24,14 @@ def __init__(self, *args) -> None: def define_node( self, node: torch.fx.Node, - nodes_to_wrappers: Dict[torch.fx.Node, PyQnnWrapper.TensorWrapper], - ) -> PyQnnWrapper.PyQnnOpWrapper: + nodes_to_wrappers: Dict[torch.fx.Node, PyQnnManager.TensorWrapper], + ) -> PyQnnManager.PyQnnOpWrapper: out_tensor = self.get_tensor(node, node) output_tensor_wrapper = self.define_tensor( node, node, out_tensor, - PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, + PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE, nodes_to_wrappers, ) xor_output_tensors = [output_tensor_wrapper] @@ -40,7 +40,7 @@ def define_node( for index in range(2): input_node = self.get_node(node.args[index]) input_tensor = self.get_tensor(input_node, node) - tensor_type = PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE + tensor_type = PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_NATIVE input_tensor_wrapper = self.define_tensor( input_node, @@ -50,7 +50,7 @@ def define_node( nodes_to_wrappers, ) xor_input_tensors.append(input_tensor_wrapper) - xor_op = PyQnnWrapper.PyQnnOpWrapper( + xor_op = PyQnnManager.PyQnnOpWrapper( node.name, QNN_OP_PACKAGE_NAME_QTI_AISW, OpElementWiseXor.op_name, diff --git a/backends/qualcomm/builders/targets.bzl b/backends/qualcomm/builders/targets.bzl index 39159e56cd8..fc7d88781cc 100644 --- a/backends/qualcomm/builders/targets.bzl +++ b/backends/qualcomm/builders/targets.bzl @@ -17,7 +17,6 @@ def define_common_targets(): deps = [ "//executorch/exir/backend:backend_details", "//executorch/exir/backend:compile_spec_schema", - "//executorch/backends/qualcomm/aot/python:PyQnnWrapperAdaptor", "//executorch/backends/qualcomm/aot/python:PyQnnManagerAdaptor", "//executorch/backends/qualcomm/utils:utils", "//executorch/exir:lib", diff --git a/backends/qualcomm/debugger/utils.py b/backends/qualcomm/debugger/utils.py index d6b91c83996..7575e0c4f35 100644 --- a/backends/qualcomm/debugger/utils.py +++ b/backends/qualcomm/debugger/utils.py @@ -7,7 +7,7 @@ from pathlib import Path from typing import Tuple -import executorch.backends.qualcomm.python.PyQnnWrapperAdaptor as PyQnnWrapper +import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager import pandas as pd import torch from executorch.backends.qualcomm.serialization.qc_schema import QcomChipset @@ -21,7 +21,7 @@ def __init__( self, filename: str, directory: str, - py_op_wrapper_list: [PyQnnWrapper.PyQnnOpWrapper], + py_op_wrapper_list: [PyQnnManager.PyQnnOpWrapper], dot_string=False, ): self.filename = filename @@ -98,13 +98,13 @@ def add_node(self, node_list, excel_data): offset = [] if ( quantization_encoding - == PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_SCALE_OFFSET + == PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_SCALE_OFFSET ): scale.append(node.quantizeParams.scaleOffsetEncoding.scale) offset.append(node.quantizeParams.scaleOffsetEncoding.offset) elif ( quantization_encoding - == PyQnnWrapper.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET + == PyQnnManager.Qnn_QuantizationEncoding_t.QNN_QUANTIZATION_ENCODING_AXIS_SCALE_OFFSET ): for i in range( node.quantizeParams.axisScaleOffsetEncoding.numScaleOffsets @@ -159,7 +159,7 @@ def to_excel(self, excel_data): offset = entry["offset"] if ( entry["tensor_type"] - == PyQnnWrapper.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC + == PyQnnManager.Qnn_TensorType_t.QNN_TENSOR_TYPE_STATIC ): param_rows.append({"name": name, "scale": scale, "offset": offset}) else: diff --git a/setup.py b/setup.py index 19f2dd0131e..f60e6202c30 100644 --- a/setup.py +++ b/setup.py @@ -759,7 +759,6 @@ def run(self): # noqa C901 if cmake_cache.is_enabled("EXECUTORCH_BUILD_QNN"): cmake_build_args += ["--target", "qnn_executorch_backend"] cmake_build_args += ["--target", "PyQnnManagerAdaptor"] - cmake_build_args += ["--target", "PyQnnWrapperAdaptor"] # Set PYTHONPATH to the location of the pip package. os.environ["PYTHONPATH"] = ( @@ -861,11 +860,5 @@ def run(self): # noqa C901 modpath="executorch.backends.qualcomm.python.PyQnnManagerAdaptor", dependent_cmake_flags=["EXECUTORCH_BUILD_QNN"], ), - BuiltExtension( - src_dir="%CMAKE_CACHE_DIR%/backends/qualcomm/%BUILD_TYPE%/", - src="PyQnnWrapperAdaptor.*", - modpath="executorch.backends.qualcomm.python.PyQnnWrapperAdaptor", - dependent_cmake_flags=["EXECUTORCH_BUILD_QNN"], - ), ], )