Skip to content

dnn(onnx): handle unaligned access in ONNX importer#16377

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
alalek:fix_16373
Jan 20, 2020
Merged

dnn(onnx): handle unaligned access in ONNX importer#16377
opencv-pushbot merged 1 commit intoopencv:3.4from
alalek:fix_16373

Conversation

@alalek
Copy link
Copy Markdown
Member

@alalek alalek commented Jan 17, 2020

resolves #16373

dkurt
dkurt previously approved these changes Jan 17, 2020
Copy link
Copy Markdown
Member

@dkurt dkurt left a comment

Choose a reason for hiding this comment

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

👍 Thank you!

@dkurt dkurt dismissed their stale review January 17, 2020 17:53

will test it locally

memcpy(aligned_val.data(), val, sz);
val = (const char*)aligned_val.data();
}
const int64_t* src = reinterpret_cast<const int64_t*>(val);
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.

Shall we do the same for floats data?

char* val = const_cast<char*>(tensor_proto.raw_data().c_str());
Mat(sizes, CV_32FC1, val).copyTo(blob);

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.

Mat::copyTo() uses type-agnostic memcpy() internally.

  • .copyTo() is safe
  • .convertTo() is not safe.

Copy link
Copy Markdown
Member

@dkurt dkurt left a comment

Choose a reason for hiding this comment

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

👍 Thanks!

opencv-pushbot pushed a commit that referenced this pull request Jan 20, 2020
@opencv-pushbot opencv-pushbot merged commit 55d54b5 into opencv:3.4 Jan 20, 2020
@alalek alalek mentioned this pull request Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug category: dnn platform: arm ARM boards related issues: RPi, NVIDIA TK/TX, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants