onnxruntime/winml/lib/Api/StringData.cpp
Tiago Koji Castro Shibata 53e7831b53
Fix Windows Store build (#8481)
* Remove APIs unavailable in Store in #8349, #8178, #8065

* Add UWP stubs of C runtime functions

* Remove UWP incompatible tests from UWP build

* Remove incompatible tests from Store

* Use UWP stubs in store only

* Skip partition check outside of Windows

* Remove unused WRL include

* Workaround Windows header not including what it uses

* Fix precompiled header name clash

* Workaround SDK bugs

* DXCore workaround in Win7

* Fix warning

* Fix more warnings

* Bump WinML to target Windows 8

* Fix more warnings

* Remove unnecessary workarounds
2021-08-10 15:19:30 -07:00

62 lines
No EOL
1.4 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "lib/Api/pch/pch.h"
#include "impl/StringData.h"
namespace _winml {
string_data::string_data(size_t size) :
buffer_(size) {}
std::shared_ptr<_winml::idata> string_data::create(size_t size) {
return std::make_shared<string_data>(size);
}
size_t string_data::num_elements() {
return buffer_.size();
}
size_t string_data::size_in_bytes() {
WINML_THROW_HR(E_UNEXPECTED);
}
size_t string_data::num_buffers() {
return 1;
}
bool string_data::flush() {
// Vacuously true
return true;
}
std::vector<wss::IBuffer>& string_data::buffers() {
WINML_THROW_HR(E_UNEXPECTED);
}
gsl::span<byte> string_data::buffer(bool /*should_sync_buffer*/) {
return gsl::span<byte>(reinterpret_cast<byte*>(buffer_.data()), buffer_.size());
}
void string_data::set(size_t num_elements, const std::string_view* data) {
WINML_THROW_HR_IF_FALSE_MSG(
E_INVALIDARG,
num_elements <= buffer_.size(),
"Argument size (%d) exceeds the tensor size (%d).",
static_cast<int>(num_elements),
static_cast<int>(buffer_.size()));
// Copy
std::copy(data, data + num_elements, buffer_.begin());
}
void string_data::set(size_t /*data_size*/, const byte* /*data*/) {
WINML_THROW_HR(E_UNEXPECTED);
}
std::vector<std::string>& string_data::get_backing_vector() {
return buffer_;
}
} // namespace _winml