Initial working python registrar.
This MR aims at allowing to define and register a python implementation which is callable by Aidge.
import aidge_core
import aidge_backend_cpu
class randomImpl(aidge_core.OperatorImpl):
def __init__(self, op: aidge_core.Operator):
print("Crating a random Impl !")
aidge_core.OperatorImpl.__init__(self, op) # Recquired to avoid type error !
self.op = op # Reference to the operator
def forward(self):
print("Random Impl called !")
def createConvImpl(op: aidge_core.Operator):
print("Pybind registrar call !")
opImpl = randomImpl(op)
return opImpl
# REGISTER NEW IMPLEMENTATION
aidge_core.register_ConvOp2D("cpu", createConvImpl)
conv = aidge_core.Conv2D(2,2,[1,1], name="Conv0")
conv.get_operator().set_backend("cpu")
input_node = aidge_core.Producer(aidge_core.Tensor(np.random.randn(1, 2, 2, 2).astype(np.float32)), name="data")
model = aidge_core.sequential([conv])
model.set_backend("cpu")
input_node.get_operator().set_backend("cpu")
input_node.get_operator().set_datatype(aidge_core.DataType.Float32)
input_node.add_child(model)
# Create SCHEDULER
scheduler = aidge_core.SequentialScheduler(model)
# Run inference !
scheduler.forward(verbose=True)