diff --git a/python/engines/arm/py_arm.h b/python/engines/arm/py_arm.h new file mode 100644 index 000000000..9e709f351 --- /dev/null +++ b/python/engines/arm/py_arm.h @@ -0,0 +1,31 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef _ST_HPC_PPL_NN_PYTHON_ARM_PY_ARM_H_ +#define _ST_HPC_PPL_NN_PYTHON_ARM_PY_ARM_H_ + +#include "pybind11/pybind11.h" + +namespace ppl { namespace nn { namespace python { namespace arm { + +void RegisterEngineFactory(pybind11::module*); +void RegisterEngineOptions(pybind11::module*); +void RegisterEngine(pybind11::module*); + +}}}} + +#endif diff --git a/python/engines/cuda/py_cuda.h b/python/engines/cuda/py_cuda.h new file mode 100644 index 000000000..f26d855b3 --- /dev/null +++ b/python/engines/cuda/py_cuda.h @@ -0,0 +1,31 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef _ST_HPC_PPL_NN_PYTHON_CUDA_PY_CUDA_H_ +#define _ST_HPC_PPL_NN_PYTHON_CUDA_PY_CUDA_H_ + +#include "pybind11/pybind11.h" + +namespace ppl { namespace nn { namespace python { namespace cuda { + +void RegisterEngineFactory(pybind11::module*); +void RegisterEngineOptions(pybind11::module*); +void RegisterEngine(pybind11::module*); + +}}}} + +#endif diff --git a/python/engines/riscv/py_riscv.h b/python/engines/riscv/py_riscv.h new file mode 100644 index 000000000..933809954 --- /dev/null +++ b/python/engines/riscv/py_riscv.h @@ -0,0 +1,31 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef _ST_HPC_PPL_NN_PYTHON_RISCV_PY_RISCV_H_ +#define _ST_HPC_PPL_NN_PYTHON_RISCV_PY_RISCV_H_ + +#include "pybind11/pybind11.h" + +namespace ppl { namespace nn { namespace python { namespace riscv { + +void RegisterEngineFactory(pybind11::module*); +void RegisterEngineOptions(pybind11::module*); +void RegisterEngine(pybind11::module*); + +}}}} + +#endif diff --git a/python/engines/x86/py_x86.h b/python/engines/x86/py_x86.h new file mode 100644 index 000000000..821eb860a --- /dev/null +++ b/python/engines/x86/py_x86.h @@ -0,0 +1,31 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef _ST_HPC_PPL_NN_PYTHON_X86_PY_X86_H_ +#define _ST_HPC_PPL_NN_PYTHON_X86_PY_X86_H_ + +#include "pybind11/pybind11.h" + +namespace ppl { namespace nn { namespace python { namespace x86 { + +void RegisterEngineFactory(pybind11::module*); +void RegisterEngineOptions(pybind11::module*); +void RegisterEngine(pybind11::module*); + +}}}} + +#endif diff --git a/python/models/onnx/py_onnx.h b/python/models/onnx/py_onnx.h new file mode 100644 index 000000000..196fefecd --- /dev/null +++ b/python/models/onnx/py_onnx.h @@ -0,0 +1,31 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef _ST_HPC_PPL_NN_PYTHON_ONNX_PY_ONNX_H_ +#define _ST_HPC_PPL_NN_PYTHON_ONNX_PY_ONNX_H_ + +#include "pybind11/pybind11.h" + +namespace ppl { namespace nn { namespace python { namespace onnx { + +void RegisterRuntimeBuilderResources(pybind11::module*); +void RegisterRuntimeBuilder(pybind11::module*); +void RegisterRuntimeBuilderFactory(pybind11::module*); + +}}}} + +#endif diff --git a/python/models/pmx/py_pmx.h b/python/models/pmx/py_pmx.h new file mode 100644 index 000000000..d8121cac5 --- /dev/null +++ b/python/models/pmx/py_pmx.h @@ -0,0 +1,33 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef _ST_HPC_PPL_NN_PYTHON_PMX_PY_PMX_H_ +#define _ST_HPC_PPL_NN_PYTHON_PMX_PY_PMX_H_ + +#include "pybind11/pybind11.h" + +namespace ppl { namespace nn { namespace python { namespace pmx { + +void RegisterRuntimeBuilderResources(pybind11::module*); +void RegisterRuntimeBuilder(pybind11::module*); +void RegisterRuntimeBuilderFactory(pybind11::module*); +void RegisterLoadModelOptions(pybind11::module*); +void RegisterSaveModelOptions(pybind11::module*); + +}}}} + +#endif diff --git a/python/py_pplnn.cc b/python/py_pplnn.cc index da520ee80..458323534 100644 --- a/python/py_pplnn.cc +++ b/python/py_pplnn.cc @@ -19,40 +19,32 @@ #include "ppl/nn/common/logger.h" using namespace ppl::common; -namespace ppl { namespace nn { namespace python { - #ifdef PPLNN_USE_CUDA -namespace cuda { -void RegisterEngineFactory(pybind11::module*); -void RegisterEngineOptions(pybind11::module*); -void RegisterEngine(pybind11::module*); -} // namespace cuda +#include "engines/cuda/py_cuda.h" #endif #ifdef PPLNN_USE_X86 -namespace x86 { -void RegisterEngineFactory(pybind11::module*); -void RegisterEngineOptions(pybind11::module*); -void RegisterEngine(pybind11::module*); -} // namespace x86 +#include "engines/x86/py_x86.h" #endif #ifdef PPLNN_USE_RISCV -namespace riscv { -void RegisterEngineFactory(pybind11::module*); -void RegisterEngineOptions(pybind11::module*); -void RegisterEngine(pybind11::module*); -} // namespace riscv +#include "engines/riscv/py_riscv.h" #endif #ifdef PPLNN_USE_ARM -namespace arm { -void RegisterEngineFactory(pybind11::module*); -void RegisterEngineOptions(pybind11::module*); -void RegisterEngine(pybind11::module*); -} // namespace arm +#include "engines/arm/py_arm.h" +#endif + +#ifdef PPLNN_ENABLE_ONNX_MODEL +#include "models/onnx/py_onnx.h" +#endif + +#ifdef PPLNN_ENABLE_PMX_MODEL +#include "models/pmx/py_pmx.h" #endif +namespace ppl { namespace nn { namespace python { + void RegisterLogger(pybind11::module*); void RegisterTensorShape(pybind11::module*); void RegisterTensor(pybind11::module*); @@ -61,27 +53,7 @@ void RegisterEngine(pybind11::module*); void RegisterDeviceContext(pybind11::module*); void RegisterRuntime(pybind11::module*); void RegisterVersion(pybind11::module*); - void RegisterModelOptionsBase(pybind11::module*); - -#ifdef PPLNN_ENABLE_ONNX_MODEL -namespace onnx { -void RegisterRuntimeBuilderResources(pybind11::module*); -void RegisterRuntimeBuilder(pybind11::module*); -void RegisterRuntimeBuilderFactory(pybind11::module*); -} // namespace onnx -#endif - -#ifdef PPLNN_ENABLE_PMX_MODEL -namespace pmx { -void RegisterRuntimeBuilderResources(pybind11::module*); -void RegisterRuntimeBuilder(pybind11::module*); -void RegisterRuntimeBuilderFactory(pybind11::module*); -void RegisterLoadModelOptions(pybind11::module*); -void RegisterSaveModelOptions(pybind11::module*); -} // namespace pmx -#endif - void LoadResources(pybind11::module*); PYBIND11_MODULE(nn, m) {