Skip to content

GAPI Fluid: Resize F32C1 scalar version.#21678

Merged
alalek merged 3 commits intoopencv:4.xfrom
anna-khakimova:ak/resize_f32c1_scalar
Mar 17, 2022
Merged

GAPI Fluid: Resize F32C1 scalar version.#21678
alalek merged 3 commits intoopencv:4.xfrom
anna-khakimova:ak/resize_f32c1_scalar

Conversation

@anna-khakimova
Copy link
Copy Markdown
Member

Resize F32C1 scalar version.

force_builders=Linux AVX2,Custom,Custom Win,Custom Mac
build_gapi_standalone:Linux x64=ade-0.1.1f
build_gapi_standalone:Win64=ade-0.1.1f
Xbuild_gapi_standalone:Mac=ade-0.1.1f
build_gapi_standalone:Linux x64 Debug=ade-0.1.1f

build_image:Custom=centos:7
buildworker:Custom=linux-1
build_gapi_standalone:Custom=ade-0.1.1f

Xbuild_image:Custom=ubuntu-openvino-2021.3.0:20.04
build_image:Custom Win=openvino-2021.4.1
build_image:Custom Mac=openvino-2021.2.0

buildworker:Custom Win=windows-3

test_modules:Custom=gapi,python2,python3,java
test_modules:Custom Win=gapi,python2,python3,java
test_modules:Custom Mac=gapi,python2,python3,java

buildworker:Custom=linux-1
# disabled due high memory usage: test_opencl:Custom=ON
Xtest_opencl:Custom=OFF
Xtest_bigdata:Custom=1
Xtest_filter:Custom=*

CPU_BASELINE:Custom Win=AVX512_SKX
CPU_BASELINE:Custom=SSE4_2

int outSz_h = saturate_cast<int>(in.size.height * fy);
GAPI_Assert(outSz_w > 0 && outSz_h > 0);
return in.withSize(Size(outSz_w, outSz_h));
return in.withType(in.depth, in.chan).withSize(Size(outSz_w, outSz_h));
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 we need to apply withType?
also we get type from in and apply it to in back - how is it supposed to be changed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It speak that type of output matrix must be the same as input type.

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.

as i see you returns copy of in which have type of in already without additional withType

Copy link
Copy Markdown
Member Author

@anna-khakimova anna-khakimova Mar 14, 2022

Choose a reason for hiding this comment

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

In GAPI_TYPED_KERNEL we always sort of return a copy of the input. These are features of the implementation of the graph. However, we must make sure that the output type matches our requirements. And if this is not so for a particular case, then such graph will not pass the check, since the checking function will swear at our attempt.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok. Applied.

auto *index = scr.mapsx;

for (int x = 0; x < outSz.width; x++) {
for (int x = 0; x < outSz.width; ++x)
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.

from my perspective modern c++ compiler is smart enough in this automatization

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not used to relying too much on compiler optimizations :-)

Unit u;

u.index0 = std::max(s - start, 0);
u.index1 = ((f == 0.0) || s + 1 >= max) ? s - start : s - start + 1;
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.

how is correct to compare f with 0.0 without epsilon?

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.

could you describe such calculations in /* comment */ please - what is it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

how is correct to compare f with 0.0 without epsilon?

Ok. Applied.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

could you describe such calculations in /* comment */ please - what is it?

This is calculation of the map of Resize F32C1. This can be understood from the name of the structure in which this method is located and from the name of the method itself. Additional comments are superfluous in my opinion.

@anna-khakimova anna-khakimova force-pushed the ak/resize_f32c1_scalar branch from 5af6268 to 72e331b Compare March 4, 2022 08:54
Copy link
Copy Markdown
Contributor

@TolyaTalamanov TolyaTalamanov left a comment

Choose a reason for hiding this comment

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

Honestly I didn't get in what cases we use:

  • GAPI_DbgAssert
  • GAPI_Assert
  • GAPI_Error

const Size& outSz,
cv::gapi::fluid::Buffer& scratch,
int lpi) {
CV_ALWAYS_INLINE void initScratchLinear(const cv::GMatDesc& in,
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.

We don't usually use CV_* macros because it might broke standalone mode.
Consider of adding synonym to there: https://github.com/opencv/opencv/blob/4.x/modules/gapi/include/opencv2/gapi/own/exports.hpp

Copy link
Copy Markdown
Member Author

@anna-khakimova anna-khakimova Mar 15, 2022

Choose a reason for hiding this comment

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

For the gfluidimgproc.cpp it is permissible to use OCV error login system and other CV_* macros, since this file is under #if !defined(GAPI_STANDALONE) guard.

To implement own GAPI error logging system and then define GAPI_Error for the Standalone mode, it's necessary to create a separate task and in bounds this task to add own error logging system for GAPI. This changes should be placed to a separate PR.

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 believe the assert.hpp one is irrelevant here?

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.

Let's keep it as CV_ anyway.

}
else
{
CV_Error(cv::Error::StsBadArg, "unsupported combination of type and number of channel");
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.

GAPI_Error?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok. GAPI_Error was added and applied.

else
{
calcRowLinearC<uint8_t, Mapper, 4>(in, out, scratch);
CV_Error(cv::Error::StsBadArg, "unsupported combination of type and number of channel");
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.

GAPI_Error

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.

Then create it :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok. GAPI_Error was added and applied.

Copy link
Copy Markdown
Contributor

@sivanov-work sivanov-work left a comment

Choose a reason for hiding this comment

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

LGTM, but please fix @TolyaTalamanov comments

Copy link
Copy Markdown
Contributor

@dmatveev dmatveev left a comment

Choose a reason for hiding this comment

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

#if !defined(GAPI_STANDALONE)
#include <opencv2/core/base.hpp>
#define GAPI_Assert CV_Assert
#define GAPI_Error CV_Error
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.

There should be a STANDALONE version defined, too.

Copy link
Copy Markdown
Member Author

@anna-khakimova anna-khakimova Mar 16, 2022

Choose a reason for hiding this comment

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

To implement own GAPI error logging system and then define GAPI_Error for the Standalone mode, it's necessary to create a separate task and in bounds this task to add own error logging system for GAPI. This changes should place to a separate PR.

Copy link
Copy Markdown
Member Author

@anna-khakimova anna-khakimova Mar 16, 2022

Choose a reason for hiding this comment

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

For the gfluidimgproc.cpp it is permissible to use OCV error login system, since this file is under #if !defined(GAPI_STANDALONE) guard.

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.

For the gfluidimgproc.cpp it is permissible to use OCV error login system, since this file is under #if !defined(GAPI_STANDALONE) guard.

Then just drop GAPI_Error, use CV_Error in your code, and file a task to implement one.

Half-defining this macro here in assert only brings confusion (as it is generic and may be used elsewhere, not only at gfluidimgproc.hpp)

const Size& outSz,
cv::gapi::fluid::Buffer& scratch,
int lpi) {
CV_ALWAYS_INLINE void initScratchLinear(const cv::GMatDesc& in,
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 believe the assert.hpp one is irrelevant here?

const Size& outSz,
cv::gapi::fluid::Buffer& scratch,
int lpi) {
CV_ALWAYS_INLINE void initScratchLinear(const cv::GMatDesc& in,
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.

Let's keep it as CV_ anyway.

@anna-khakimova anna-khakimova force-pushed the ak/resize_f32c1_scalar branch from 21899cc to 9ae70cc Compare March 16, 2022 12:52
@anna-khakimova
Copy link
Copy Markdown
Member Author

@dmatveev Ok. The GAPI_Error define was reverted.

@anna-khakimova anna-khakimova requested a review from dmatveev March 16, 2022 12:57
Copy link
Copy Markdown
Contributor

@dmatveev dmatveev left a comment

Choose a reason for hiding this comment

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

👍

@anna-khakimova
Copy link
Copy Markdown
Member Author

@alalek Could you please take a look this PR?

#define GAPI_Assert(expr) \
{ if (!(expr)) ::detail::assert_abort(#expr, __LINE__, __FILE__, __func__); }


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please avoid unnecessary changes in patches

@alalek alalek merged commit 48cd2d1 into opencv:4.x Mar 17, 2022
@opencv-pushbot opencv-pushbot mentioned this pull request Apr 23, 2022
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
…calar

GAPI Fluid: Resize F32C1 scalar version.

* GAPI Fluid: Resize F32C1 scalar.

* Final version

* Applied comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants