Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
1188c6fe
Commit
1188c6fe
authored
Oct 17, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12838 from dmatveev:gapi_fluid_resize_lpi
parents
5339ef30
922d5796
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
14 deletions
+39
-14
gfluidbackend.cpp
modules/gapi/src/backends/fluid/gfluidbackend.cpp
+35
-13
gfluidbackend.hpp
modules/gapi/src/backends/fluid/gfluidbackend.hpp
+4
-1
gapi_fluid_resize_test.cpp
modules/gapi/test/gapi_fluid_resize_test.cpp
+0
-0
No files found.
modules/gapi/src/backends/fluid/gfluidbackend.cpp
View file @
1188c6fe
...
@@ -102,6 +102,7 @@ private:
...
@@ -102,6 +102,7 @@ private:
virtual
int
linesRead
()
const
override
;
virtual
int
linesRead
()
const
override
;
public
:
public
:
using
FluidAgent
::
FluidAgent
;
using
FluidAgent
::
FluidAgent
;
virtual
void
setInHeight
(
int
)
override
{
/* nothing */
}
};
};
struct
FluidResizeAgent
:
public
FluidAgent
struct
FluidResizeAgent
:
public
FluidAgent
...
@@ -112,6 +113,7 @@ private:
...
@@ -112,6 +113,7 @@ private:
virtual
int
linesRead
()
const
override
;
virtual
int
linesRead
()
const
override
;
public
:
public
:
using
FluidAgent
::
FluidAgent
;
using
FluidAgent
::
FluidAgent
;
virtual
void
setInHeight
(
int
)
override
{
/* nothing */
}
};
};
struct
FluidUpscaleAgent
:
public
FluidAgent
struct
FluidUpscaleAgent
:
public
FluidAgent
...
@@ -120,8 +122,11 @@ private:
...
@@ -120,8 +122,11 @@ private:
virtual
int
firstWindow
()
const
override
;
virtual
int
firstWindow
()
const
override
;
virtual
int
nextWindow
()
const
override
;
virtual
int
nextWindow
()
const
override
;
virtual
int
linesRead
()
const
override
;
virtual
int
linesRead
()
const
override
;
int
m_inH
;
public
:
public
:
using
FluidAgent
::
FluidAgent
;
using
FluidAgent
::
FluidAgent
;
virtual
void
setInHeight
(
int
h
)
override
{
m_inH
=
h
;
}
};
};
}}
// namespace cv::gimpl
}}
// namespace cv::gimpl
...
@@ -207,21 +212,24 @@ static int calcResizeWindow(int inH, int outH)
...
@@ -207,21 +212,24 @@ static int calcResizeWindow(int inH, int outH)
}
}
}
}
static
int
max
ReadWindow
(
const
cv
::
GFluidKernel
&
k
,
int
inH
,
int
outH
)
static
int
max
LineConsumption
(
const
cv
::
GFluidKernel
&
k
,
int
inH
,
int
outH
,
int
lpi
)
{
{
switch
(
k
.
m_kind
)
switch
(
k
.
m_kind
)
{
{
case
cv
:
:
GFluidKernel
::
Kind
::
Filter
:
return
k
.
m_window
;
break
;
case
cv
:
:
GFluidKernel
::
Kind
::
Filter
:
return
k
.
m_window
+
lpi
-
1
;
break
;
case
cv
:
:
GFluidKernel
::
Kind
::
Resize
:
case
cv
:
:
GFluidKernel
::
Kind
::
Resize
:
{
{
if
(
inH
>=
outH
)
if
(
inH
>=
outH
)
{
{
return
calcResizeWindow
(
inH
,
outH
);
// FIXME:
// This is a suboptimal value, can be reduced
return
calcResizeWindow
(
inH
,
outH
)
*
lpi
;
}
}
else
else
{
{
// Upscale always has window of 2
// FIXME:
return
(
inH
==
1
)
?
1
:
2
;
// This is a suboptimal value, can be reduced
return
(
inH
==
1
)
?
1
:
2
+
lpi
-
1
;
}
}
}
break
;
}
break
;
default
:
GAPI_Assert
(
false
);
return
0
;
default
:
GAPI_Assert
(
false
);
return
0
;
...
@@ -297,37 +305,45 @@ int cv::gimpl::FluidFilterAgent::linesRead() const
...
@@ -297,37 +305,45 @@ int cv::gimpl::FluidFilterAgent::linesRead() const
int
cv
::
gimpl
::
FluidResizeAgent
::
firstWindow
()
const
int
cv
::
gimpl
::
FluidResizeAgent
::
firstWindow
()
const
{
{
auto
outIdx
=
out_buffers
[
0
]
->
priv
().
y
();
auto
outIdx
=
out_buffers
[
0
]
->
priv
().
y
();
return
windowEnd
(
outIdx
,
m_ratio
)
-
windowStart
(
outIdx
,
m_ratio
);
auto
lpi
=
std
::
min
(
m_outputLines
-
m_producedLines
,
k
.
m_lpi
);
return
windowEnd
(
outIdx
+
lpi
-
1
,
m_ratio
)
-
windowStart
(
outIdx
,
m_ratio
);
}
}
int
cv
::
gimpl
::
FluidResizeAgent
::
nextWindow
()
const
int
cv
::
gimpl
::
FluidResizeAgent
::
nextWindow
()
const
{
{
auto
outIdx
=
out_buffers
[
0
]
->
priv
().
y
();
auto
outIdx
=
out_buffers
[
0
]
->
priv
().
y
();
return
windowEnd
(
outIdx
+
1
,
m_ratio
)
-
windowStart
(
outIdx
+
1
,
m_ratio
);
auto
lpi
=
std
::
min
(
m_outputLines
-
m_producedLines
-
k
.
m_lpi
,
k
.
m_lpi
);
auto
nextStartIdx
=
outIdx
+
1
+
k
.
m_lpi
-
1
;
auto
nextEndIdx
=
nextStartIdx
+
lpi
-
1
;
return
windowEnd
(
nextEndIdx
,
m_ratio
)
-
windowStart
(
nextStartIdx
,
m_ratio
);
}
}
int
cv
::
gimpl
::
FluidResizeAgent
::
linesRead
()
const
int
cv
::
gimpl
::
FluidResizeAgent
::
linesRead
()
const
{
{
auto
outIdx
=
out_buffers
[
0
]
->
priv
().
y
();
auto
outIdx
=
out_buffers
[
0
]
->
priv
().
y
();
return
windowStart
(
outIdx
+
1
,
m_ratio
)
-
windowStart
(
outIdx
,
m_ratio
);
return
windowStart
(
outIdx
+
1
+
k
.
m_lpi
-
1
,
m_ratio
)
-
windowStart
(
outIdx
,
m_ratio
);
}
}
int
cv
::
gimpl
::
FluidUpscaleAgent
::
firstWindow
()
const
int
cv
::
gimpl
::
FluidUpscaleAgent
::
firstWindow
()
const
{
{
auto
outIdx
=
out_buffers
[
0
]
->
priv
().
y
();
auto
outIdx
=
out_buffers
[
0
]
->
priv
().
y
();
return
upscaleWindowEnd
(
outIdx
,
m_ratio
,
in_views
[
0
].
meta
().
size
.
height
)
-
upscaleWindowStart
(
outIdx
,
m_ratio
);
auto
lpi
=
std
::
min
(
m_outputLines
-
m_producedLines
,
k
.
m_lpi
);
return
upscaleWindowEnd
(
outIdx
+
lpi
-
1
,
m_ratio
,
m_inH
)
-
upscaleWindowStart
(
outIdx
,
m_ratio
);
}
}
int
cv
::
gimpl
::
FluidUpscaleAgent
::
nextWindow
()
const
int
cv
::
gimpl
::
FluidUpscaleAgent
::
nextWindow
()
const
{
{
auto
outIdx
=
out_buffers
[
0
]
->
priv
().
y
();
auto
outIdx
=
out_buffers
[
0
]
->
priv
().
y
();
return
upscaleWindowEnd
(
outIdx
+
1
,
m_ratio
,
in_views
[
0
].
meta
().
size
.
height
)
-
upscaleWindowStart
(
outIdx
+
1
,
m_ratio
);
auto
lpi
=
std
::
min
(
m_outputLines
-
m_producedLines
-
k
.
m_lpi
,
k
.
m_lpi
);
auto
nextStartIdx
=
outIdx
+
1
+
k
.
m_lpi
-
1
;
auto
nextEndIdx
=
nextStartIdx
+
lpi
-
1
;
return
upscaleWindowEnd
(
nextEndIdx
,
m_ratio
,
m_inH
)
-
upscaleWindowStart
(
nextStartIdx
,
m_ratio
);
}
}
int
cv
::
gimpl
::
FluidUpscaleAgent
::
linesRead
()
const
int
cv
::
gimpl
::
FluidUpscaleAgent
::
linesRead
()
const
{
{
auto
outIdx
=
out_buffers
[
0
]
->
priv
().
y
();
auto
outIdx
=
out_buffers
[
0
]
->
priv
().
y
();
return
upscaleWindowStart
(
outIdx
+
1
,
m_ratio
)
-
upscaleWindowStart
(
outIdx
,
m_ratio
);
return
upscaleWindowStart
(
outIdx
+
1
+
k
.
m_lpi
-
1
,
m_ratio
)
-
upscaleWindowStart
(
outIdx
,
m_ratio
);
}
}
bool
cv
::
gimpl
::
FluidAgent
::
canRead
()
const
bool
cv
::
gimpl
::
FluidAgent
::
canRead
()
const
...
@@ -707,6 +723,13 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
...
@@ -707,6 +723,13 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
}
}
}
}
// cache input height to avoid costly meta() call
// (actually cached and used only in upscale)
if
(
agent
->
in_views
[
0
])
{
agent
->
setInHeight
(
agent
->
in_views
[
0
].
meta
().
size
.
height
);
}
// b. Agent output parameters with Buffer pointers.
// b. Agent output parameters with Buffer pointers.
agent
->
out_buffers
.
resize
(
agent
->
op_handle
->
outEdges
().
size
(),
nullptr
);
agent
->
out_buffers
.
resize
(
agent
->
op_handle
->
outEdges
().
size
(),
nullptr
);
for
(
auto
it
:
ade
::
util
::
zip
(
ade
::
util
::
iota
(
agent
->
out_buffers
.
size
()),
for
(
auto
it
:
ade
::
util
::
zip
(
ade
::
util
::
iota
(
agent
->
out_buffers
.
size
()),
...
@@ -993,8 +1016,7 @@ void GFluidBackendImpl::addBackendPasses(ade::ExecutionEngineSetupContext &ectx)
...
@@ -993,8 +1016,7 @@ void GFluidBackendImpl::addBackendPasses(ade::ExecutionEngineSetupContext &ectx)
auto
&
fu
=
fg
.
metadata
(
node
).
get
<
FluidUnit
>
();
auto
&
fu
=
fg
.
metadata
(
node
).
get
<
FluidUnit
>
();
fu
.
ratio
=
(
double
)
in_h
/
out_h
;
fu
.
ratio
=
(
double
)
in_h
/
out_h
;
int
w
=
maxReadWindow
(
fu
.
k
,
in_h
,
out_h
);
int
line_consumption
=
maxLineConsumption
(
fu
.
k
,
in_h
,
out_h
,
fu
.
k
.
m_lpi
);
int
line_consumption
=
fu
.
k
.
m_lpi
+
w
-
1
;
int
border_size
=
borderSize
(
fu
.
k
);
int
border_size
=
borderSize
(
fu
.
k
);
fu
.
border_size
=
border_size
;
fu
.
border_size
=
border_size
;
...
...
modules/gapi/src/backends/fluid/gfluidbackend.hpp
View file @
1188c6fe
...
@@ -82,7 +82,10 @@ public:
...
@@ -82,7 +82,10 @@ public:
bool
done
()
const
;
bool
done
()
const
;
void
debug
(
std
::
ostream
&
os
);
void
debug
(
std
::
ostream
&
os
);
// FIXME:
// refactor (implement a more solid replacement or
// drop this method completely)
virtual
void
setInHeight
(
int
h
)
=
0
;
private
:
private
:
// FIXME!!!
// FIXME!!!
// move to another class
// move to another class
...
...
modules/gapi/test/gapi_fluid_resize_test.cpp
View file @
1188c6fe
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment