[OperatorImpl] Python OperatorImpl
-
Bind OperatorImpl so that it can be extended on Python side -
Add Operator.setImpl
method -
Replace std::getenv("AIDGE_CORE_WITH_PYBIND") with Py_IsInitialized() (fix #24 (closed)) -
Add unittest
Usage example
import aidge_core
class PythonReluImpl(aidge_core.OperatorImpl):
def __init__(self, op):
aidge_core.OperatorImpl.__init__(self) # Recquired to avoid type error !
def forward(self):
print("Forward defined in Python !")
custom_relu = aidge_core.GenericOperator("Relu", 1, 1, 1, name="myReLu")
custom_relu_op = custom_relu.get_operator()
custom_relu_op.forward()
custom_relu_op.set_impl(PythonReluImpl(custom_relu_op))
custom_relu_op.forward()
Edited by Cyril Moineau