Skip to content

Commit 41bacd8

Browse files
dbortfacebook-github-bot
authored andcommitted
Migrate backends/qualcomm to the new namespace (#6025)
Summary: Pull Request resolved: #6025 Move the qualcomm backend out of the `torch::` namespace, and update to avoid using the `torch::` or `exec_aten::` namespaces. Reviewed By: cccclai Differential Revision: D64073805
1 parent b6e6d06 commit 41bacd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+485
-392
lines changed

backends/qualcomm/aot/ir/qcir_utils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
#include <unordered_map>
1313

14-
namespace torch {
15-
namespace executor {
14+
namespace executorch {
15+
namespace backends {
1616
namespace qnn {
1717

1818
qcir::TensorType ToTensorType(Qnn_TensorType_t type) {
@@ -278,5 +278,5 @@ Qnn_Tensor_t ToTensor(const tensor_type& tensor) {
278278
}
279279

280280
} // namespace qnn
281-
} // namespace executor
282-
} // namespace torch
281+
} // namespace backends
282+
} // namespace executorch

backends/qualcomm/aot/ir/qcir_utils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include <executorch/backends/qualcomm/aot/ir/qcir_generated.h>
1212
#include "QnnTypes.h"
1313

14-
namespace torch {
15-
namespace executor {
14+
namespace executorch {
15+
namespace backends {
1616
namespace qnn {
1717

1818
typedef flatbuffers::Vector<::flatbuffers::Offset<qcir::Tensor>>::return_type
@@ -36,5 +36,5 @@ flatbuffers::Offset<qcir::Tensor> ToTensor(
3636
Qnn_Tensor_t ToTensor(const tensor_type& tensor);
3737

3838
} // namespace qnn
39-
} // namespace executor
40-
} // namespace torch
39+
} // namespace backends
40+
} // namespace executorch

backends/qualcomm/aot/python/PyQnnManagerAdaptor.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
#include <pybind11/pybind11.h>
1010

1111
namespace py = pybind11;
12-
namespace torch {
13-
namespace executor {
12+
namespace executorch {
13+
namespace backends {
1414
namespace qnn {
15+
16+
using executorch::runtime::Error;
17+
1518
PYBIND11_MODULE(PyQnnManagerAdaptor, m) {
1619
// TODO: Add related documents for configurations listed below
1720
using namespace qnn_delegate;
@@ -39,5 +42,5 @@ PYBIND11_MODULE(PyQnnManagerAdaptor, m) {
3942
.def("GetSpillFillBufferSize", &PyQnnManager::GetSpillFillBufferSize);
4043
}
4144
} // namespace qnn
42-
} // namespace executor
43-
} // namespace torch
45+
} // namespace backends
46+
} // namespace executorch

backends/qualcomm/aot/python/PyQnnManagerAdaptor.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <string_view>
2020

2121
namespace py = pybind11;
22-
namespace torch {
23-
namespace executor {
22+
namespace executorch {
23+
namespace backends {
2424
namespace qnn {
2525
class PyQnnManager {
2626
public:
@@ -48,7 +48,7 @@ class PyQnnManager {
4848
qnn_executorch_options, qnn_executorch_context_binary_);
4949
}
5050

51-
Error Init() {
51+
executorch::runtime::Error Init() {
5252
return qnn_manager_->Init();
5353
}
5454
bool IsNodeSupportedByBackend(
@@ -97,8 +97,8 @@ class PyQnnManager {
9797
wrapper->SetName(param->GetName());
9898
set_tensor(wrapper, params);
9999
} else {
100-
Error err = param->PopulateQnnParam();
101-
if (err != Error::Ok) {
100+
executorch::runtime::Error err = param->PopulateQnnParam();
101+
if (err != executorch::runtime::Error::Ok) {
102102
QNN_EXECUTORCH_LOG_ERROR(
103103
"Fail to get scalar parameter in online prepare stage");
104104
return py::array_t<char>(0);
@@ -131,7 +131,8 @@ class PyQnnManager {
131131
context_binary.buffer = builder.GetBufferPointer();
132132
context_binary.nbytes = builder.GetSize();
133133
} else if (
134-
qnn_manager_->Compile(op_wrappers, context_binary) != Error::Ok) {
134+
qnn_manager_->Compile(op_wrappers, context_binary) !=
135+
executorch::runtime::Error::Ok) {
135136
return py::array_t<char>(0);
136137
}
137138

@@ -155,7 +156,7 @@ class PyQnnManager {
155156
return qnn_manager_->IsTensorDump();
156157
}
157158

158-
Error AllocateTensor() {
159+
executorch::runtime::Error AllocateTensor() {
159160
return qnn_manager_->AllocateTensor();
160161
}
161162

@@ -189,5 +190,5 @@ class PyQnnManager {
189190
std::shared_ptr<QnnManager> qnn_manager_;
190191
};
191192
} // namespace qnn
192-
} // namespace executor
193-
} // namespace torch
193+
} // namespace backends
194+
} // namespace executorch

backends/qualcomm/aot/python/PyQnnWrapperAdaptor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include <string>
1616

1717
namespace py = pybind11;
18-
namespace torch {
19-
namespace executor {
18+
namespace executorch {
19+
namespace backends {
2020
namespace qnn {
2121
std::unique_ptr<QuantizeParamsWrapper> CreateQuantizationParamWrapper(
2222
const Qnn_QuantizationEncoding_t& encoding,
@@ -250,5 +250,5 @@ PYBIND11_MODULE(PyQnnWrapperAdaptor, m) {
250250
.def("GetEncodings", &PyQnnTensorWrapper::GetEncodings);
251251
}
252252
} // namespace qnn
253-
} // namespace executor
254-
} // namespace torch
253+
} // namespace backends
254+
} // namespace executorch

backends/qualcomm/aot/python/PyQnnWrapperAdaptor.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include <pybind11/pybind11.h>
1515
#include <pybind11/stl.h>
1616
namespace py = pybind11;
17-
namespace torch {
18-
namespace executor {
17+
namespace executorch {
18+
namespace backends {
1919
namespace qnn {
2020
class PyQnnOpWrapper {
2121
public:
@@ -183,5 +183,5 @@ class PyQnnTensorWrapper {
183183
std::shared_ptr<TensorWrapper> tensor_wrapper_;
184184
};
185185
} // namespace qnn
186-
} // namespace executor
187-
} // namespace torch
186+
} // namespace backends
187+
} // namespace executorch

backends/qualcomm/aot/wrappers/OpWrapper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88
#include <executorch/backends/qualcomm/aot/wrappers/OpWrapper.h>
9-
namespace torch {
10-
namespace executor {
9+
namespace executorch {
10+
namespace backends {
1111
namespace qnn {
1212
Qnn_OpConfig_t OpWrapper::GetOpConfig() {
1313
param_types_.clear();
@@ -44,5 +44,5 @@ Qnn_OpConfig_t OpWrapper::GetOpConfig() {
4444
return ret;
4545
}
4646
} // namespace qnn
47-
} // namespace executor
48-
} // namespace torch
47+
} // namespace backends
48+
} // namespace executorch

backends/qualcomm/aot/wrappers/OpWrapper.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include <memory>
1818
#include <sstream>
1919
#include <typeinfo>
20-
namespace torch {
21-
namespace executor {
20+
namespace executorch {
21+
namespace backends {
2222
namespace qnn {
2323
class OpWrapper final {
2424
public:
@@ -116,5 +116,5 @@ class OpWrapper final {
116116
std::vector<Qnn_Param_t> param_types_;
117117
};
118118
} // namespace qnn
119-
} // namespace executor
120-
} // namespace torch
119+
} // namespace backends
120+
} // namespace executorch

backends/qualcomm/aot/wrappers/ParamWrapper.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@
1313
#include <utility>
1414

1515
#include "QnnTypes.h"
16-
namespace torch {
17-
namespace executor {
16+
namespace executorch {
17+
namespace backends {
1818
namespace qnn {
19+
20+
using executorch::runtime::Error;
21+
1922
class ParamWrapper {
2023
public:
2124
// Populate Qnn_Param_t. Return an error code Error::Ok if succeeded,
2225
// Error::Internal if failed
23-
virtual Error PopulateQnnParam() = 0;
26+
virtual executorch::runtime::Error PopulateQnnParam() = 0;
2427
virtual ~ParamWrapper() = default;
2528

2629
ParamWrapper(const ParamWrapper& rhs) = default;
@@ -50,5 +53,5 @@ class ParamWrapper {
5053
std::string name_;
5154
};
5255
} // namespace qnn
53-
} // namespace executor
54-
} // namespace torch
56+
} // namespace backends
57+
} // namespace executorch

backends/qualcomm/aot/wrappers/QuantizeParamsWrapper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88
#include <executorch/backends/qualcomm/aot/wrappers/QuantizeParamsWrapper.h>
99
#include <executorch/backends/qualcomm/runtime/Logging.h>
10-
namespace torch {
11-
namespace executor {
10+
namespace executorch {
11+
namespace backends {
1212
namespace qnn {
1313
std::unique_ptr<QuantizeParamsWrapper> CreateQuantizationParamWrapper(
1414
const Qnn_QuantizeParams_t& quantization) {
@@ -69,5 +69,5 @@ std::unique_ptr<QuantizeParamsWrapper> CreateQuantizationParamWrapper(
6969
return quantize_param_wrapper;
7070
}
7171
} // namespace qnn
72-
} // namespace executor
73-
} // namespace torch
72+
} // namespace backends
73+
} // namespace executorch

backends/qualcomm/aot/wrappers/QuantizeParamsWrapper.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <vector>
1313

1414
#include "QnnTypes.h"
15-
namespace torch {
16-
namespace executor {
15+
namespace executorch {
16+
namespace backends {
1717
namespace qnn {
1818
class QuantizeParamsWrapper {
1919
public:
@@ -285,5 +285,5 @@ class AxisScaleOffsetQuantizeParamsWrapper final
285285
std::unique_ptr<QuantizeParamsWrapper> CreateQuantizationParamWrapper(
286286
const Qnn_QuantizeParams_t& quantization);
287287
} // namespace qnn
288-
} // namespace executor
289-
} // namespace torch
288+
} // namespace backends
289+
} // namespace executorch

backends/qualcomm/aot/wrappers/ScalarParamWrapper.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
#include <executorch/backends/qualcomm/aot/wrappers/ParamWrapper.h>
1111
#include <executorch/runtime/core/error.h>
12-
namespace torch {
13-
namespace executor {
12+
namespace executorch {
13+
namespace backends {
1414
namespace qnn {
1515
template <typename T>
1616
class ScalarParamWrapper final : public ParamWrapper {
@@ -25,7 +25,7 @@ class ScalarParamWrapper final : public ParamWrapper {
2525

2626
// Populate appropriate field in Qnn scalarParam depending on the datatype
2727
// of the scalar
28-
Error PopulateQnnParam() override {
28+
executorch::runtime::Error PopulateQnnParam() override {
2929
qnn_param_.scalarParam.dataType = data_type_;
3030
switch (data_type_) {
3131
case QNN_DATATYPE_BOOL_8:
@@ -57,9 +57,9 @@ class ScalarParamWrapper final : public ParamWrapper {
5757
"ScalarParamWrapper failed to assign scalarParam value - "
5858
"invalid datatype %d",
5959
data_type_);
60-
return Error::Internal;
60+
return executorch::runtime::Error::Internal;
6161
}
62-
return Error::Ok;
62+
return executorch::runtime::Error::Ok;
6363
}
6464

6565
const T& GetData() const {
@@ -71,5 +71,5 @@ class ScalarParamWrapper final : public ParamWrapper {
7171
T data_;
7272
};
7373
} // namespace qnn
74-
} // namespace executor
75-
} // namespace torch
74+
} // namespace backends
75+
} // namespace executorch

backends/qualcomm/aot/wrappers/TensorParamWrapper.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
#include <memory>
1515

16-
namespace torch {
17-
namespace executor {
16+
namespace executorch {
17+
namespace backends {
1818
namespace qnn {
1919
class TensorParamWrapper final : public ParamWrapper {
2020
public:
@@ -24,12 +24,12 @@ class TensorParamWrapper final : public ParamWrapper {
2424
: ParamWrapper(QNN_PARAMTYPE_TENSOR, std::move(name)),
2525
static_tensor_wrapper_(std::move(static_tensor)) {}
2626
// Populate Qnn tensorParam with tensor wrapper
27-
Error PopulateQnnParam() override {
28-
// Error out if underlying tensor is not static:
27+
executorch::runtime::Error PopulateQnnParam() override {
28+
// executorch::runtime::Error out if underlying tensor is not static:
2929
if (!static_tensor_wrapper_->IsTensorStatic())
30-
return Error::Internal;
30+
return executorch::runtime::Error::Internal;
3131
qnn_param_.tensorParam = static_tensor_wrapper_->CloneTensorStruct();
32-
return Error::Ok;
32+
return executorch::runtime::Error::Ok;
3333
}
3434

3535
// Accessor functions:
@@ -45,5 +45,5 @@ class TensorParamWrapper final : public ParamWrapper {
4545
std::shared_ptr<TensorWrapper> static_tensor_wrapper_;
4646
};
4747
} // namespace qnn
48-
} // namespace executor
49-
} // namespace torch
48+
} // namespace backends
49+
} // namespace executorch

backends/qualcomm/aot/wrappers/TensorWrapper.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
#include <cstring>
1313
#include <limits>
1414
#include <numeric>
15-
namespace torch {
16-
namespace executor {
15+
namespace executorch {
16+
namespace backends {
1717
namespace qnn {
18+
19+
using executorch::runtime::Error;
20+
1821
std::uint32_t GetDataTypeSize(Qnn_DataType_t data_type) {
1922
std::uint32_t size = 0;
2023

@@ -214,5 +217,5 @@ std::shared_ptr<TensorWrapper> CreateTensorWrapper(const Qnn_Tensor_t& tensor) {
214217
QNN_VER_PTR(tensor)->clientBuf.data);
215218
}
216219
} // namespace qnn
217-
} // namespace executor
218-
} // namespace torch
220+
} // namespace backends
221+
} // namespace executorch

0 commit comments

Comments
 (0)