utensor_cgen icon indicating copy to clipboard operation
utensor_cgen copied to clipboard

Pre/Post Transform/Apply Observer

Open dboyliao opened this issue 5 years ago • 2 comments

Implement an interface for users to register pre/post transformation/apply observers for BackendPart and Transformer.

@classmethod
def regiseter_prior_observer(cls, callback):
    cls.prior_observer.append(callback)

@classmethod
def register_post_observer(cls, callback):
    # similar code

def apply(self, ugraph):
    for callback in type(self).prior_observer:
        callback(ugraph)
    # do work with ugraph
    for callback in type(self).prior_observer:
        callback(ugraph)

Unify the interface for users to inspect the graph, such as inject pdb break point in the callback. Note that these observers should not introduce side-effect to the graph.

dboyliao avatar Mar 20 '20 15:03 dboyliao

@mbartling

dboyliao avatar Mar 20 '20 15:03 dboyliao

Looks good to me!

mbartling avatar Apr 17 '20 19:04 mbartling