Skip to content

About

本プロジェクトは、C++による高速な深層学習アルゴリズムの実装をPythonから利用可能にするために、pybind11を用いてバインディングしたものです。ニューラルネットワークの学習・推論処理の一部をC++で実装することで計算効率を向上させ、Python側では実験やモデル設計を柔軟に行える構成になっています。

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

pybindの使い方

setup.pyとexample.cppを記載後 python setup.py build_ext --inplaceでコンパイル で作ったc++のファイルをコンパイル

使用方法

pythonの他ファイルで import example print(example.add(3, 5)) # 8 のように実行

setup.py

from setuptools import setup, Extension import pybind11

ext_modules = [ Extension( 'example', # Pythonから import するモジュール名 ['example.cpp'], # C++ファイル include_dirs=[pybind11.get_include()], language='c++' ), ]

setup( name='example', ext_modules=ext_modules, )

example.cpp

#include <pybind11/pybind11.h>

namespace py = pybind11;

// C++で作った関数 int add(int i, int j) { return i + j; }

// モジュール定義 PYBIND11_MODULE(example, m) { m.doc() = "pybind11 example plugin"; // モジュールの説明 m.def("add", &add, "A function which adds two numbers"); }

//python setup.py build_ext --inplaceでコンパイル

About

本プロジェクトは、C++による高速な深層学習アルゴリズムの実装をPythonから利用可能にするために、pybind11を用いてバインディングしたものです。ニューラルネットワークの学習・推論処理の一部をC++で実装することで計算効率を向上させ、Python側では実験やモデル設計を柔軟に行える構成になっています。

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages