Skip to content

Commit b8f66f9

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 fbshipit-source-id: d0ab30f598a337367cebb1be3a1b6d94285da9f0
1 parent c4a2eeb commit b8f66f9

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

0 commit comments

Comments
 (0)