mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-17 21:10:43 +00:00
* switch to work PC * back with iterable of buffers * add raw api tests * tensorization * last test * all tests pass! * small cleanup * whitespace * newline * whitespace * refactor common code into DisjointBufferHelpers * remove unused file * warning * skip gpu tests when hardware not available * Add error condition when createreference is invoked * add null check to cretereference * uncomment out check Co-authored-by: Sheil Kumar <sheilk@microsoft.com>
34 lines
1,021 B
C++
34 lines
1,021 B
C++
#include "pch.h"
|
|
#include "inc/DisjointBufferHelpers.h"
|
|
|
|
namespace _winml {
|
|
|
|
void LoadOrStoreDisjointBuffers(
|
|
bool should_load_buffer,
|
|
size_t num_buffers,
|
|
std::function<gsl::span<byte>(size_t)> get_buffer,
|
|
gsl::span<byte>& buffer_span) {
|
|
auto size_in_bytes = buffer_span.size_bytes();
|
|
auto buffer = buffer_span.data();
|
|
size_t offset_in_bytes = 0;
|
|
for (size_t i = 0; i < num_buffers && size_in_bytes > offset_in_bytes; i++) {
|
|
auto span = get_buffer(i);
|
|
auto current_size_in_bytes = span.size_bytes();
|
|
auto current_buffer = span.data();
|
|
|
|
if (size_in_bytes - offset_in_bytes < current_size_in_bytes) {
|
|
current_size_in_bytes = size_in_bytes - offset_in_bytes;
|
|
}
|
|
|
|
auto offset_buffer = buffer + offset_in_bytes;
|
|
if (should_load_buffer) {
|
|
memcpy(offset_buffer, current_buffer, current_size_in_bytes);
|
|
} else {
|
|
memcpy(current_buffer, offset_buffer, current_size_in_bytes);
|
|
}
|
|
|
|
offset_in_bytes += current_size_in_bytes;
|
|
}
|
|
}
|
|
|
|
} // namespace _winml
|