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
e0fe0aa3
Commit
e0fe0aa3
authored
May 29, 2017
by
dkurt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix reshape layer output size computation
parent
27f6d4e7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
reshape_layer.cpp
modules/dnn/src/layers/reshape_layer.cpp
+14
-0
test_torch_importer.cpp
modules/dnn/test/test_torch_importer.cpp
+1
-0
No files found.
modules/dnn/src/layers/reshape_layer.cpp
View file @
e0fe0aa3
...
...
@@ -55,6 +55,7 @@ static void computeShapeByReshapeMask(const MatShape &srcShape,
{
int
srcShapeSize
=
(
int
)
srcShape
.
size
();
int
maskShapeSize
=
(
int
)
maskShape
.
size
();
int
maskTotal
=
abs
(
total
(
maskShape
));
// Mask might have negative ones.
if
(
srcRange
==
Range
::
all
())
srcRange
=
Range
(
0
,
srcShapeSize
);
...
...
@@ -65,6 +66,19 @@ static void computeShapeByReshapeMask(const MatShape &srcShape,
srcRange
.
end
=
srcRange
.
end
==
INT_MAX
?
srcShapeSize
:
srcRange
.
start
+
sz
;
}
if
(
maskTotal
!=
0
)
{
for
(
int
i
=
srcRange
.
start
+
1
;
i
<
srcRange
.
end
;
++
i
)
{
if
(
total
(
srcShape
,
i
,
srcRange
.
end
)
!=
maskTotal
)
{
srcRange
.
start
=
i
-
1
;
break
;
}
}
CV_Assert
(
total
(
srcShape
,
srcRange
.
start
,
srcRange
.
end
)
==
maskTotal
);
}
CV_Assert
(
0
<=
srcRange
.
start
&&
srcRange
.
start
<=
srcRange
.
end
&&
srcRange
.
end
<=
srcShapeSize
);
int
dstShapeSize
=
srcShapeSize
-
srcRange
.
size
()
+
maskShapeSize
;
dstShape
.
resize
(
dstShapeSize
);
...
...
modules/dnn/test/test_torch_importer.cpp
View file @
e0fe0aa3
...
...
@@ -122,6 +122,7 @@ TEST(Torch_Importer, run_reshape)
{
runTorchNet
(
"net_reshape"
);
runTorchNet
(
"net_reshape_batch"
);
runTorchNet
(
"net_reshape_single_sample"
);
}
TEST
(
Torch_Importer
,
run_linear
)
...
...
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