forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from JunnYu/convert_paddle_not_equal_op
[PaddlePaddle hackathon] + convert paddle "not_equal" op
- Loading branch information
Showing
6 changed files
with
68 additions
and
0 deletions.
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
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
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
43 changes: 43 additions & 0 deletions
43
ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_not_equal.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,43 @@ | ||
# | ||
# not_equal paddle model generator | ||
# | ||
import numpy as np | ||
from save_model import saveModel | ||
import sys | ||
|
||
|
||
def not_equal(name : str, x, y): | ||
import paddle as pdpd | ||
pdpd.enable_static() | ||
|
||
node_x = pdpd.static.data(name='x', shape=x.shape, dtype='float32') | ||
node_y = pdpd.static.data(name='y', shape=y.shape, dtype='float32') | ||
|
||
out = pdpd.not_equal(node_x, node_y) | ||
out = pdpd.cast(out, np.float32) | ||
|
||
cpu = pdpd.static.cpu_places(1) | ||
exe = pdpd.static.Executor(cpu[0]) | ||
# startup program will call initializer to initialize the parameters. | ||
exe.run(pdpd.static.default_startup_program()) | ||
|
||
outs = exe.run( | ||
feed={'x': x, 'y': y}, | ||
fetch_list=[out]) | ||
|
||
saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], | ||
inputs=[x, y], outputs=[outs[0]], target_dir=sys.argv[1]) | ||
|
||
return outs[0] | ||
|
||
|
||
def main(): | ||
import paddle as pdpd | ||
data_x = np.array([[[[-1, 0, 1]], [[2, 3, 4]]]]).astype(np.float32) | ||
data_y = np.array([[[[2, 0, 3]], [[3, 1, 4]]]]).astype(np.float32) | ||
|
||
not_equal("not_equal", data_x, data_y) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |