Revise SoftPlus operation reference implementation 37559#5938
Revise SoftPlus operation reference implementation 37559#5938ilyachur merged 17 commits intoopenvinotoolkit:masterfrom
Conversation
docs/ops/activation/SoftPlus_4.md
Outdated
| 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**: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Why do you use hardcoded value (Why 20?)?
There was a problem hiding this comment.
@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.
…otoolkit#5892)" This reverts commit 115aa14.
…penvinotoolkit#5892)"" This reverts commit 95afa50.
This reverts commit 91af825.
This reverts commit a3b232a.
| 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); |
There was a problem hiding this comment.
Can you add more tests (for visit_attributes)?
https://github.com/openvinotoolkit/openvino/tree/master/ngraph/test/visitors/op
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
thanks for reminder, I have added it, please help check it.
There was a problem hiding this comment.
@ilyachur is this PR ok to be merged into master?
ngraph/test/visitors/op/softplus.cpp
Outdated
| using ngraph::test::NodeBuilder; | ||
| using ngraph::test::ValueMap; | ||
|
|
||
| TEST(attributes, softplus) |
There was a problem hiding this comment.
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
…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
Details:
Tickets: