Skip to content

Commit

Permalink
Merge pull request #12 from JunnYu/convert_paddle_not_equal_op
Browse files Browse the repository at this point in the history
[PaddlePaddle hackathon] + convert paddle "not_equal" op
  • Loading branch information
openvino-dev-samples authored Nov 11, 2021
2 parents cc15f85 + 8ed0c60 commit adfe253
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .ci/azure/linux.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
trigger:
branches:
include:
- master
- releases/*
paths:
exclude:
- docs/*

resources:
repositories:
- repository: openvino_contrib
Expand Down
9 changes: 9 additions & 0 deletions .ci/azure/windows.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
trigger:
branches:
include:
- master
- releases/*
paths:
exclude:
- docs/*

resources:
repositories:
- repository: openvino_contrib
Expand Down
4 changes: 4 additions & 0 deletions ngraph/frontend/paddlepaddle/src/op/elementwise_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ NamedOutputs elementwise_greater_equal(const NodeContext& node_context) {
return elementwise_ops<ngraph::opset6::GreaterEqual>(node_context);
}

NamedOutputs elementwise_not_equal(const NodeContext& node_context) {
return elementwise_ops<ngraph::opset6::NotEqual>(node_context);
}

} // namespace op
} // namespace pdpd
} // namespace frontend
Expand Down
2 changes: 2 additions & 0 deletions ngraph/frontend/paddlepaddle/src/op_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ OP_CONVERTER(elementwise_greater_equal);
OP_CONVERTER(elementwise_max);
OP_CONVERTER(elementwise_min);
OP_CONVERTER(elementwise_mul);
OP_CONVERTER(elementwise_not_equal);
OP_CONVERTER(elementwise_pow);
OP_CONVERTER(elementwise_sub);
OP_CONVERTER(embedding);
Expand Down Expand Up @@ -132,6 +133,7 @@ std::map<std::string, CreatorFunction> get_supported_ops() {
{"multiclass_nms3", op::multiclass_nms},
{"nearest_interp_v2", op::nearest_interp_v2},
{"nearest_interp", op::nearest_interp_v2},
{"not_equal", op::elementwise_not_equal},
{"pad3d", op::pad3d},
{"pow", op::pow},
{"pool2d", op::pool2d},
Expand Down
1 change: 1 addition & 0 deletions ngraph/test/frontend/paddlepaddle/op_fuzzy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ static const std::vector<std::string> models{std::string("argmax"),
std::string("nearest_downsample_false_1"),
std::string("nearest_upsample_false_0"),
std::string("nearest_upsample_false_1"),
std::string("not_equal"),
std::string("pad3d_test1"),
std::string("pad3d_test2"),
std::string("pad3d_test3"),
Expand Down
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()

0 comments on commit adfe253

Please sign in to comment.