Skip to content

Revise SoftPlus operation reference implementation 37559#5938

Merged
ilyachur merged 17 commits intoopenvinotoolkit:masterfrom
yding10:softplus
Jun 22, 2021
Merged

Revise SoftPlus operation reference implementation 37559#5938
ilyachur merged 17 commits intoopenvinotoolkit:masterfrom
yding10:softplus

Conversation

@yding10
Copy link
Copy Markdown
Contributor

@yding10 yding10 commented Jun 1, 2021

Details:

  • improve the input type error check
  • add invalid input error test case
  • add backend test case
  • add attribute test case

Tickets:

  • 37559

@yding10 yding10 requested a review from a team June 1, 2021 01:55
@yding10 yding10 changed the title Revise SoftPlus operation reference implementation Revise SoftPlus operation reference implementation 37559 Jun 1, 2021
@openvino-pushbot openvino-pushbot added ExternalIntelPR External contributor from Intel category: Core OpenVINO Core (aka ngraph) labels Jun 1, 2021
@yding10 yding10 marked this pull request as draft June 1, 2021 02:20
@yding10 yding10 marked this pull request as ready for review June 1, 2021 07:44
@yding10 yding10 requested a review from a team as a code owner June 1, 2021 07:44
@yding10 yding10 removed the ExternalIntelPR External contributor from Intel label Jun 2, 2021
is chosen in such a way that the difference between the linear function and exact calculation is no more than `1e-6`.
The `threshold` can be calculated with the following formula where `alpha` is the number of digits after the decimal point,
`beta` is maximum value of *T* data type:
**Note**:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lazarevevgeny Could you please take a look?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with these changes. @a-sidorova did analysis and provided a formulae to calculate the threshold based on the data type. We should use this approach and do not hardcode any constants in the specification.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, revert back. update after getting alignemnt by email.

void softplus(const T* arg, T* out, size_t count)
{
const T threshold = static_cast<T>(std::log(std::numeric_limits<T>::max()));
const T threshold = 20.0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use hardcoded value (Why 20?)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilyachur current implementation is not aligned with spec. threshold is a range that we can choose from, 20 is chosen for FP32 based on experiment, to align to the spec and cpu-plugin implementation. for FP16, it is also working that no overflow will happen as calculation is based on FP32 and converted to FP16 at final stage. So either we change the spec or change the code here to get it aligned.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert back ..

@ilyachur ilyachur requested a review from lazarevevgeny June 2, 2021 05:46
@ilyachur ilyachur added this to the 2022.1 milestone Jun 2, 2021
@yding10 yding10 requested a review from a-sidorova June 2, 2021 07:07
@yding10 yding10 requested review from a team June 4, 2021 02:46
@yding10 yding10 requested review from ilyachur and lazarevevgeny June 7, 2021 07:11
void op::v4::SoftPlus::validate_and_infer_types()
{
NGRAPH_OP_SCOPE(v4_SoftPlus_validate_and_infer_types);
const element::Type& input_et = get_input_element_type(0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no attribute for this op. the "threshold" we discussed before is an internal defined parameter, which is not exposed to user. is it ok not to add test for visit_attributes?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we need to add tests for such operations too.

Example you can find here: https://github.com/openvinotoolkit/openvino/blob/master/ngraph/test/visitors/op/result.cpp

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for reminder, I have added it, please help check it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilyachur is this PR ok to be merged into master?

using ngraph::test::NodeBuilder;
using ngraph::test::ValueMap;

TEST(attributes, softplus)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi could you please rebase your PR to the latest master. And please use parametrized visitor API test which was introduced in this PR: #6181

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@ilyachur ilyachur merged commit 5ce5f9e into openvinotoolkit:master Jun 22, 2021
rnugmanx pushed a commit to rnugmanx/openvino that referenced this pull request Aug 26, 2021
…lkit#5938)

* change threshold to 20 instead of max limit of data type

* add invalid input type test case

* add invalid input data check

* add input type dynamic check

* add backend test case

* add more clarity on spec and align with real implementation

* Revert "[CPU] Fix for  CoreThreadingTestsWithIterations tests (openvinotoolkit#5892)"

This reverts commit 115aa14.

* Revert "Revert "[CPU] Fix for  CoreThreadingTestsWithIterations tests (openvinotoolkit#5892)""

This reverts commit 95afa50.

* Revert "change threshold to 20 instead of max limit of data type"

This reverts commit 91af825.

* Revert "add more clarity on spec and align with real implementation"

This reverts commit a3b232a.

* add visitor attribute test case

* Revert "add visitor attribute test case"

This reverts commit 610728f.

* add attribute test case

* revise the attribute visitor test per parametrized visitor API PR: openvinotoolkit#6181
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: Core OpenVINO Core (aka ngraph)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants