-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 4】add paddle linspace op #15835
【PaddlePaddle Hackathon 4】add paddle linspace op #15835
Conversation
src/frontends/paddle/tests/test_models/gen_scripts/generate_linspace.py
Outdated
Show resolved
Hide resolved
src/frontends/paddle/tests/test_models/gen_scripts/generate_linspace.py
Outdated
Show resolved
Hide resolved
// generate a range of numbers [0, 1, ..., num) | ||
auto const_zero = std::make_shared<default_opset::Constant>(start.get_element_type(), Shape{}, 0); | ||
auto const_num = std::make_shared<default_opset::Squeeze>(num); | ||
auto range0_n = std::make_shared<default_opset::Range>(const_zero, const_num, const_one, start.get_element_type()); |
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.
I just wonder can we use range
for a direct output ? so we do not need Multiply
and Add
, just a guess
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.
great idea, it is important to simplify the operator code. but the behavior of Range
is subtly different from Linspace
even though their input parameters are similar with each other. Using Range
for a direct output maybe require the overal re-design of linspace
.
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.
Thanks, could you clarify what's gap between them? can we convert the num in Linspace into step in Range
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.
step
can be calculated by num
, which has already implemented in line 30 of linspace.cpp
. The key point is the behavior of Range
. For instance, same input (start: [0] stop: [1] num: [4]/step: [0.33]), and the result will be:
Range
: [0, 0.33, 0.66]
Linspace
: [0, 0.33, 0.66, 1]
And the input of Range must be scalar, which means must be taken before range operator.
I think it will become more complicate after adjusting the code.
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.
Great thanks for your illustration
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.
Can start
and stop
be negative here, and can you put this example ( (start: [0] stop: [1] num: [4]/step: [0.33])) into your test case, thanks?
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.
OK,test samples had been added
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.
Would you please rebase and resolve the conflicts?
conflicts resoved |
Hello could you also post a English version of Paddle Op description, thanks |
namespace paddle { | ||
namespace op { | ||
NamedOutputs linspace(const NodeContext& node) { | ||
auto start = node.get_input("Start"); |
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.
Hi, @OpenVINO-dev-contest
|
Sorry I missed it. but shall we consider the
Sorry, I missed it, but shall we consider the |
The python frontend of paddle could ensure that the input type and attr |
Can you update the uni-test with these case example ? for example input type is fp32 and dtype is int32. just ensure the Paddle front end will do conversion for us. |
sorry, I misunderstood the function of |
auto stop = node.get_input("Stop"); | ||
auto num = node.get_input("Num"); | ||
std::unordered_map<int, element::Type> umap{{2, element::i32}, {3, element::i64}, {5, element::f32}}; | ||
const auto dtype = node.get_attribute<int>("dtype", 5); |
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.
can we use auto dtype = node.get_attribute<ov::element::Type>("dtype");
to get the the type ?
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
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.
Pls add a screenshot of test results, thanks
Can one of the admins verify this patch? |
Details:
add linspace operation in Paddle front end
Reference:
Unit-Test