Skip to content

Commit

Permalink
[misc] move func decl to separate headers
Browse files Browse the repository at this point in the history
  • Loading branch information
ouonline committed Jan 24, 2024
1 parent e8a6049 commit 9db1d4f
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 42 deletions.
31 changes: 31 additions & 0 deletions python/engines/arm/py_arm.h
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions python/engines/cuda/py_cuda.h
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions python/engines/riscv/py_riscv.h
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions python/engines/x86/py_x86.h
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions python/models/onnx/py_onnx.h
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions python/models/pmx/py_pmx.h
Original file line number Diff line number Diff line change
@@ -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
56 changes: 14 additions & 42 deletions python/py_pplnn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand All @@ -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) {
Expand Down

0 comments on commit 9db1d4f

Please sign in to comment.