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

[PaddlePaddle hackathon] not_equal #15

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -130,6 +131,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 @@ -162,6 +162,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
import paddle as pdpd
from save_model import saveModel
import sys

data_type = "float32"

def not_equal(name : str, x, y):
pdpd.enable_static()

node_x = pdpd.static.data(name='x', shape=x.shape, dtype=data_type)
node_y = pdpd.static.data(name='y', shape=y.shape, dtype=data_type)

out = pdpd.not_equal(node_x, node_y)
out = pdpd.cast(out, data_type)

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():
data_x = np.array([[[[-5, -1, 3]], [[1, 9, 2]]]]).astype(data_type)
data_y = np.array([[[[1, -1, 2]], [[3, -4, 9]]]]).astype(data_type)

not_equal("not_equal", data_x, data_y)


if __name__ == "__main__":
main()