PaddlePaddle / PaddleSOT

A Bytecode level Implementation of Symbolic OpCode Translator For PaddlePaddle
Apache License 2.0
15 stars 25 forks source link

[SideEffect] add side effects support for ObjectVariable #393

Closed gouzil closed 1 year ago

gouzil commented 1 year ago

为什么需要支持ObjectVariable的 side effects

class CustomObject:
    def __init__(self, a):
        self.a = a

def object_delattr(cus_obj):
    del cus_obj.a

x = CustomObject(1)
symbolic_translate(object_delattr)(x)
print(dir(x))
# ['__class__', ... , 'a']

x2 = CustomObject(1)
object_delattr(x2)
print(dir(x2))
# ['__class__', ... , '__weakref__']

目前还存在的问题:

close: #307