-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
【Hackathon 5th No.97】add paddle tanh_shrink op #20067
Merged
Merged
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
36f9650
Add paddle tanh_shrink conversion
Asthestarsfalll b755605
update
Asthestarsfalll c6ef9bc
Merge branch 'master' into tanh_shrink
Asthestarsfalll d9d4915
update
Asthestarsfalll 6765f61
Merge branch 'master' into tanh_shrink
Asthestarsfalll 7f3f20c
restore CMakeLists.txt and waitting for PD test build enabled
Asthestarsfalll d6145ae
update for unittests
Asthestarsfalll d3b9274
Merge branch 'master' into tanh_shrink
Asthestarsfalll 69d7914
remove code
Asthestarsfalll af07787
Merge branch 'master' into tanh_shrink
Asthestarsfalll 7452fac
Add paddle tanh_shrink conversion
Asthestarsfalll f033104
Merge branch 'master' of https://github.com/openvinotoolkit/openvino …
Asthestarsfalll 0a00cf8
Merge branch 'tanh_shrink' of https://github.com/Asthestarsfalll/open…
Asthestarsfalll 0c01f23
Merge branch 'master' into tanh_shrink
xczhai 493ba97
Merge branch 'master' into tanh_shrink
ceciliapeng2011 6a2e9c4
Merge branch 'master' into tanh_shrink
Asthestarsfalll b76254a
Merge branch 'master' into tanh_shrink
Asthestarsfalll 6eefebe
Merge branch 'master' into tanh_shrink
xczhai File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "default_opset.hpp" | ||
#include "openvino/frontend/paddle/node_context.hpp" | ||
|
||
namespace ov { | ||
namespace frontend { | ||
namespace paddle { | ||
namespace op { | ||
NamedOutputs tanh_shrink(const NodeContext& node) { | ||
const auto x = node.get_input("X"); | ||
const auto tanh = std::make_shared<default_opset::Tanh>(x); | ||
return node.default_single_output_mapping({std::make_shared<default_opset::Subtract>(x, tanh)}, {"Out"}); | ||
} | ||
|
||
} // namespace op | ||
} // namespace paddle | ||
} // namespace frontend | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/frontends/paddle/tests/test_models/gen_scripts/generate_tanh_shrink.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright (C) 2018-2023 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# | ||
# tanh_shrink paddle model generator | ||
# | ||
import numpy as np | ||
import sys | ||
from save_model import saveModel | ||
|
||
|
||
def tanh_shrink(name: str, x): | ||
import paddle | ||
|
||
paddle.enable_static() | ||
|
||
with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): | ||
node_x = paddle.static.data(name='x', shape=x.shape, dtype=x.dtype) | ||
out = paddle.nn.functional.tanhshrink(node_x) | ||
|
||
cpu = paddle.static.cpu_places(1) | ||
exe = paddle.static.Executor(cpu[0]) | ||
# startup program will call initializer to initialize the parameters. | ||
exe.run(paddle.static.default_startup_program()) | ||
|
||
outs = exe.run(feed={'x': x}, fetch_list=[out]) | ||
|
||
saveModel( | ||
name, | ||
exe, | ||
feedkeys=['x'], | ||
fetchlist=[out], | ||
inputs=[x], | ||
outputs=[outs[0]], | ||
target_dir=sys.argv[1], | ||
) | ||
|
||
return outs[0] | ||
|
||
|
||
def main(): | ||
data = np.random.uniform(10, 20, [2, 3, 4]).astype(np.float32) | ||
tanh_shrink("tanh_shrink_1", data) | ||
|
||
data = np.random.uniform(-10, 20, [4, 3, 2]).astype(np.float32) | ||
tanh_shrink("tanh_shrink_2", data) | ||
|
||
# data = np.random.uniform(10, 20, [2, 3, 4]).astype(np.float16) // only on gpu | ||
# tanh_shrink("tanh_shrink_3", data) | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove the useless codes if unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done