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 logxxx to log comp xxx rewriter where xxx = sigmoid or softmax #4925

Merged
merged 4 commits into from
Aug 15, 2023

Conversation

lrw04
Copy link
Contributor

@lrw04 lrw04 commented Aug 8, 2023

The patch adds passes to pnnx's pass_ncnn that rewrites logsigmoid/logsoftmax nodes into compositions of log nodes and sigmoid/softmax nodes.

@lrw04
Copy link
Contributor Author

lrw04 commented Aug 8, 2023

Note that this is not a templated implementation; it rewrites logsigmoid/logsoftmax nodes only and will not adapt to additions of operators in the future.

@lrw04 lrw04 changed the title Add logxxx to log comp xxx rewriter Add logxxx to log comp xxx rewriter where xxx = sigmoid or softmax Aug 8, 2023
@lrw04
Copy link
Contributor Author

lrw04 commented Aug 8, 2023

I prefer this over making softmax/sigmoid layers also act as logsoftmax/logsigmoid layers since that would be unnatural.

@nihui
Copy link
Member

nihui commented Aug 9, 2023

please add test for the nn.module style ones

@lrw04
Copy link
Contributor Author

lrw04 commented Aug 9, 2023

I believe they were already added in the earliest commit, at /tools/pnnx/tests/ncnn/test_nn_{LogSigmoid.py,LogSoftmax.py}.

@nihui nihui merged commit fed3b43 into Tencent:master Aug 15, 2023
7 checks passed
@nihui
Copy link
Member

nihui commented Aug 15, 2023

Thanks for your contribution !

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.

None yet

2 participants