mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-06 00:03:22 +00:00
Improved documentation for onnxruntime::utils::SwapByteOrderCopy(), added precondition check.
This commit is contained in:
parent
be12cdc73f
commit
8647201ac7
2 changed files with 12 additions and 5 deletions
|
|
@ -32,6 +32,10 @@ void SwapByteOrderCopy(
|
|||
assert(element_size_in_bytes > 0);
|
||||
assert(source_bytes.size_bytes() % element_size_in_bytes == 0);
|
||||
assert(source_bytes.size_bytes() == destination_bytes.size_bytes());
|
||||
// check non-overlapping
|
||||
// given begin <= end, end0 <= begin1 || end1 <= begin0
|
||||
assert(source_bytes.data() + source_bytes.size() <= destination_bytes.data() ||
|
||||
destination_bytes.data() + destination_bytes.size() <= source_bytes.data());
|
||||
|
||||
for (size_t element_offset = 0, element_offset_end = source_bytes.size_bytes();
|
||||
element_offset < element_offset_end;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,14 @@ namespace onnxruntime {
|
|||
namespace utils {
|
||||
|
||||
/**
|
||||
* Swaps the byte order of elements in a buffer.
|
||||
* This is a low-level funtion - please be sure to pass in valid arguments.
|
||||
* In particular, source_bytes and destination_bytes should have the same size,
|
||||
* which should be a multiple of element_size_in_bytes. element_size_in_bytes
|
||||
* should also be greater than zero.
|
||||
* Copies elements and swaps their byte orders.
|
||||
*
|
||||
* This is a low-level function - please be sure to pass in valid arguments.
|
||||
* In particular:
|
||||
* - source_bytes and destination_bytes should have the same size, which should
|
||||
* be a multiple of element_size_in_bytes.
|
||||
* - element_size_in_bytes should be greater than zero.
|
||||
* - source_bytes and destination_bytes should not overlap.
|
||||
*
|
||||
* @param element_size_in_bytes The size of an individual element, in bytes.
|
||||
* @param source_bytes The source byte span.
|
||||
|
|
|
|||
Loading…
Reference in a new issue