Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for trace function #8

Merged
merged 1 commit into from
Feb 21, 2023
Merged

Conversation

SigureMo
Copy link
Collaborator

@SigureMo SigureMo commented Feb 20, 2023

#2 的一个 TODO,尝试简单支持了下 Callable(仅支持函数,不支持显式重载 __call__ 的 Callable object,试了下 torch.fx 也是不支持的),keyword args 还没支持~

> python examples/simple_callable_trace.py

python IR:
opcode         name    target                          args      kwargs
-------------  ------  ------------------------------  --------  --------------------
placeholder    x       x                               ()        {}
placeholder    y       y                               ()        {}
call_function  mul     <built-in function mul>         (x, x)    {}
call_function  add     <built-in function add>         (mul, y)  {}
call_function  add     <function add at 0x13fc54430>   ()        {'x': add, 'y': add}
call_function  relu    <function relu at 0x16c09b2e0>  ()        {'x': add}
output         output  output                          (relu,)   {}
python code generated:
mul = x * x
add = mul + y
add = paddle.tensor.math.add(x = add, y = add)
relu = paddle.nn.functional.activation.relu(x = add)
return (relu,)

@SigureMo SigureMo changed the title add support for trace callable object add support for trace function Feb 20, 2023
Copy link
Collaborator

@gglin001 gglin001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@gglin001
Copy link
Collaborator

I have intived you as the admin for this repo, please check your email @SigureMo

@gglin001 gglin001 merged commit 8512254 into PFCCLab:main Feb 21, 2023
@SigureMo SigureMo deleted the trace-callable branch February 21, 2023 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants