Skip to content
Snippets Groups Projects
Commit b00cc2ba authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Merged with main

parents 9e4cdbb9 8228ba63
No related branches found
No related tags found
1 merge request!16Unified interface for attributes
Pipeline #32391 passed with warnings
...@@ -6,16 +6,19 @@ You can find here the C++ code of the Core library of Aidge. ...@@ -6,16 +6,19 @@ You can find here the C++ code of the Core library of Aidge.
## Pip installation ## Pip installation
To install aidge_core using pip, make sure to set the desired install path :
``` bash
export AIDGE_INSTALL = '<path_to_aidge>/install'
```
Then run in your python environnement :
To install aidge_core using pip, run the following command in your python environnement :
``` bash ``` bash
pip install . -v pip install . -v
``` ```
**Note:** you can specify a custom install folder by setting an environment variable:
``` bash
export AIDGE_INSTALL='<path_to_aidge>/install'
```
## Standard C++ Compilation ## Standard C++ Compilation
Create two directories ``build`` and ``ìnstall``. Create two directories ``build`` and ``ìnstall``.
......
...@@ -67,5 +67,15 @@ class test_operator_binding(unittest.TestCase): ...@@ -67,5 +67,15 @@ class test_operator_binding(unittest.TestCase):
self.generic_operator.add_attr("l_str", ["ok"]) self.generic_operator.add_attr("l_str", ["ok"])
self.assertEqual(self.generic_operator.get_attr("l_str"), ["ok"]) self.assertEqual(self.generic_operator.get_attr("l_str"), ["ok"])
def test_compute_output_dims(self):
in_dims=[25, 25]
input = aidge_core.Producer(in_dims, name="In")
genOp = aidge_core.GenericOperator("genOp", 1, 1, 1, name="genOp")
_ = aidge_core.sequential([input, genOp])
self.assertListEqual(genOp.get_operator().output(0).dims(), [])
genOp.get_operator().set_compute_output_dims(lambda x:x)
genOp.get_operator().compute_output_dims()
self.assertListEqual(genOp.get_operator().output(0).dims(), in_dims)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
\ No newline at end of file
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
#include <pybind11/stl.h> #include <pybind11/stl.h>
#include <pybind11/functional.h>
#include <stdio.h> #include <stdio.h>
#include "aidge/backend/OperatorImpl.hpp" #include "aidge/backend/OperatorImpl.hpp"
...@@ -21,7 +22,11 @@ namespace Aidge { ...@@ -21,7 +22,11 @@ namespace Aidge {
void init_GenericOperator(py::module& m) { void init_GenericOperator(py::module& m) {
py::class_<GenericOperator_Op, std::shared_ptr<GenericOperator_Op>, Operator, DynamicAttributes>(m, "GenericOperatorOp", py::class_<GenericOperator_Op, std::shared_ptr<GenericOperator_Op>, Operator, DynamicAttributes>(m, "GenericOperatorOp",
py::multiple_inheritance()); py::multiple_inheritance())
.def_readonly_static("identity", &GenericOperator_Op::Identity)
.def("compute_output_dims", &GenericOperator_Op::computeOutputDims)
.def("set_compute_output_dims", &GenericOperator_Op::setComputeOutputDims, py::arg("computation_function"));
m.def("GenericOperator", &GenericOperator, py::arg("type"), py::arg("nbDataIn"), py::arg("nbIn"), py::arg("nbOut"), m.def("GenericOperator", &GenericOperator, py::arg("type"), py::arg("nbDataIn"), py::arg("nbIn"), py::arg("nbOut"),
py::arg("name") = ""); py::arg("name") = "");
} }
......
...@@ -62,11 +62,11 @@ class CMakeBuild(build_ext): ...@@ -62,11 +62,11 @@ class CMakeBuild(build_ext):
os.chdir(str(build_temp)) os.chdir(str(build_temp))
# Impose to use the executable of the python # Impose to use the executable of the python
# used to launch setup.py to setup PythonInterp # used to launch setup.py to setup PythonInterp
param_py = "-DPYTHON_EXECUTABLE=" + sys.executable param_py = "-DPYTHON_EXECUTABLE=" + sys.executable
install_path = f"{build_temp}/install" if "AIDGE_INSTALL" not in os.environ else os.environ["AIDGE_INSTALL"] install_path = os.path.join(sys.prefix, "lib", "libAidge") if "AIDGE_INSTALL" not in os.environ else os.environ["AIDGE_INSTALL"]
self.spawn(['cmake', str(cwd), param_py, '-DTEST=OFF', f'-DCMAKE_INSTALL_PREFIX:PATH={install_path}']) self.spawn(['cmake', str(cwd), param_py, '-DTEST=OFF', f'-DCMAKE_INSTALL_PREFIX:PATH={install_path}'])
if not self.dry_run: if not self.dry_run:
...@@ -83,11 +83,11 @@ class CMakeBuild(build_ext): ...@@ -83,11 +83,11 @@ class CMakeBuild(build_ext):
for file in files: for file in files:
if file.endswith('.so') and (root != str(aidge_package.absolute())): if file.endswith('.so') and (root != str(aidge_package.absolute())):
currentFile=os.path.join(root, file) currentFile=os.path.join(root, file)
shutil.copy(currentFile, str(aidge_package.absolute())) shutil.copy(currentFile, str(aidge_package.absolute()))
# Copy version.txt in aidge_package # Copy version.txt in aidge_package
os.chdir(os.path.dirname(__file__)) os.chdir(os.path.dirname(__file__))
shutil.copy("version.txt", str(aidge_package.absolute())) shutil.copy("version.txt", str(aidge_package.absolute()))
if __name__ == '__main__': if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment