Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
80d35faf
Commit
80d35faf
authored
Jul 21, 2016
by
Anna Petrovicheva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Permute layer
parent
355d07ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
permute_layer.cpp
modules/dnn/src/layers/permute_layer.cpp
+14
-10
permute_layer.hpp
modules/dnn/src/layers/permute_layer.hpp
+1
-1
No files found.
modules/dnn/src/layers/permute_layer.cpp
View file @
80d35faf
...
...
@@ -88,13 +88,15 @@ PermuteLayer::PermuteLayer(LayerParams ¶ms) : Layer(params)
}
DictValue
paramOrder
=
params
.
get
(
"order"
);
if
(
paramOrder
.
size
()
!=
4
)
if
(
paramOrder
.
size
()
>
4
)
{
CV_Error
(
Error
::
StsBadArg
,
"
4 orders of dimensions in Permute layer parameter is required
"
);
"
Too many (> 4) orders of dimensions in Permute layer
"
);
}
_numAxes
=
paramOrder
.
size
();
for
(
size_t
i
=
0
;
i
<
_numAxes
;
i
++
)
{
int
currentOrder
=
paramOrder
.
get
<
int
>
(
i
);
...
...
@@ -110,13 +112,13 @@ void PermuteLayer::computeStrides()
_oldStride
.
resize
(
_numAxes
);
_newStride
.
resize
(
_numAxes
);
_oldStride
[
3
]
=
1
;
_newStride
[
3
]
=
1
;
_oldStride
[
_numAxes
-
1
]
=
1
;
_newStride
[
_numAxes
-
1
]
=
1
;
for
(
int
i
=
2
;
i
>=
0
;
i
--
)
for
(
int
i
=
_numAxes
-
2
;
i
>=
0
;
i
--
)
{
_oldStride
[
i
]
=
_oldStride
[
i
-
1
]
*
_oldDimensionSize
[
i
-
1
];
_newStride
[
i
]
=
_newStride
[
i
-
1
]
*
_newDimensionSize
[
i
-
1
];
_oldStride
[
i
]
=
_oldStride
[
i
+
1
]
*
_oldDimensionSize
[
i
+
1
];
_newStride
[
i
]
=
_newStride
[
i
+
1
]
*
_newDimensionSize
[
i
+
1
];
}
_count
=
_oldStride
[
0
]
*
_oldDimensionSize
[
0
];
...
...
@@ -130,6 +132,8 @@ void PermuteLayer::allocate(const std::vector<Blob*> &inputs, std::vector<Blob>
}
CV_Assert
(
inputs
.
size
()
>
0
);
CV_Assert
((
int
)
_numAxes
==
inputs
[
0
]
->
shape
().
dims
());
outputs
.
resize
(
inputs
.
size
());
_oldDimensionSize
=
inputs
[
0
]
->
shape
();
...
...
@@ -158,10 +162,10 @@ void PermuteLayer::forward(std::vector<Blob*> &inputs, std::vector<Blob> &output
return
;
}
for
(
size_t
j
=
0
;
j
<
inputs
.
size
();
j
++
)
for
(
size_t
k
=
0
;
k
<
inputs
.
size
();
k
++
)
{
float
*
srcData
=
inputs
[
j
]
->
ptrf
();
float
*
dstData
=
outputs
[
j
].
ptrf
();
float
*
srcData
=
inputs
[
k
]
->
ptrf
();
float
*
dstData
=
outputs
[
k
].
ptrf
();
for
(
size_t
i
=
0
;
i
<
_count
;
++
i
)
{
...
...
modules/dnn/src/layers/permute_layer.hpp
View file @
80d35faf
...
...
@@ -59,7 +59,7 @@ class PermuteLayer : public Layer
std
::
vector
<
size_t
>
_newStride
;
bool
_needsPermute
;
s
tatic
const
size_t
_numAxes
=
4
;
s
ize_t
_numAxes
;
void
checkCurrentOrder
(
int
currentOrder
);
void
checkNeedForPermutation
();
...
...
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