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
55d54b56
Commit
55d54b56
authored
5 years ago
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dnn(onnx): handle unaligned access in ONNX importer
parent
16b13c6e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
onnx_importer.cpp
modules/dnn/src/onnx/onnx_importer.cpp
+12
-2
No files found.
modules/dnn/src/onnx/onnx_importer.cpp
View file @
55d54b56
...
...
@@ -147,8 +147,18 @@ Mat getMatFromTensor(opencv_onnx::TensorProto& tensor_proto)
}
else
{
char
*
val
=
const_cast
<
char
*>
(
tensor_proto
.
raw_data
().
c_str
());
int64_t
*
src
=
reinterpret_cast
<
int64_t
*>
(
val
);
const
char
*
val
=
tensor_proto
.
raw_data
().
c_str
();
// Aligned pointer is required: https://github.com/opencv/opencv/issues/16373
// this doesn't work: typedef int64_t CV_DECL_ALIGNED(1) unaligned_int64_t;
AutoBuffer
<
int64_t
,
16
>
aligned_val
;
if
(
!
isAligned
<
sizeof
(
int64_t
)
>
(
val
))
{
size_t
sz
=
tensor_proto
.
raw_data
().
size
();
aligned_val
.
allocate
(
divUp
(
sz
,
sizeof
(
int64_t
)));
memcpy
(
aligned_val
.
data
(),
val
,
sz
);
val
=
(
const
char
*
)
aligned_val
.
data
();
}
const
int64_t
*
src
=
reinterpret_cast
<
const
int64_t
*>
(
val
);
convertInt64ToInt32
(
src
,
dst
,
blob
.
total
());
}
}
...
...
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