1 /*
2 * Copyright (c) Qualcomm Innovation Center, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree.
7 */
8 #include <executorch/backends/qualcomm/aot/python/PyQnnManagerAdaptor.h>
9 #include <pybind11/pybind11.h>
10
11 namespace py = pybind11;
12 namespace executorch {
13 namespace backends {
14 namespace qnn {
15
16 using executorch::runtime::Error;
17
PYBIND11_MODULE(PyQnnManagerAdaptor,m)18 PYBIND11_MODULE(PyQnnManagerAdaptor, m) {
19 // TODO: Add related documents for configurations listed below
20 using namespace qnn_delegate;
21
22 py::class_<QnnExecuTorchContextBinary>(m, "QnnExecuTorchContextBinary")
23 .def(py::init<>());
24
25 py::enum_<Error>(m, "Error")
26 .value("Ok", Error::Ok)
27 .value("Internal", Error::Internal)
28 .export_values();
29
30 py::class_<PyQnnManager, std::shared_ptr<PyQnnManager>>(m, "QnnManager")
31 .def(py::init<const py::bytes&>())
32 .def(py::init<const py::bytes&, const py::bytes&>())
33 .def(py::init<const py::bytes&, const py::list&>())
34 .def("Init", &PyQnnManager::Init)
35 .def("IsNodeSupportedByBackend", &PyQnnManager::IsNodeSupportedByBackend)
36 .def("Compile", py::overload_cast<>(&PyQnnManager::Compile))
37 .def(
38 "Compile",
39 py::overload_cast<
40 const std::string&,
41 std::vector<std::shared_ptr<OpWrapper>>&>(&PyQnnManager::Compile))
42 .def("Destroy", &PyQnnManager::Destroy)
43 .def("IsAvailable", &PyQnnManager::IsAvailable)
44 .def("IsTensorDump", &PyQnnManager::IsTensorDump)
45 .def("AllocateTensor", &PyQnnManager::AllocateTensor)
46 .def("GetGraphInputs", &PyQnnManager::GetGraphInputs)
47 .def("GetGraphOutputs", &PyQnnManager::GetGraphOutputs)
48 .def("GetGraphNames", &PyQnnManager::GetGraphNames)
49 .def("GetSpillFillBufferSize", &PyQnnManager::GetSpillFillBufferSize)
50 .def(
51 "MakeBinaryInfo",
52 py::overload_cast<const py::bytes&>(&PyQnnManager::MakeBinaryInfo));
53 }
54 } // namespace qnn
55 } // namespace backends
56 } // namespace executorch
57