mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-16 21:00:14 +00:00
* model building * fix build * winml adapter model building api * model building * make build * make build again * add model building with audio op * inplace and inorder fft * add ifft * works! * cleanup * add comments * switch to iterative rather than recursive and use parallelization * batched parallelization * fft->dft * cleanup * window functions * add melweightmatrix op * updates to make spectrogram test work * push latest * add onesided * cleanup * Clean up building apis and fix mel * cleanup * cleanup * naive stft * fix test output * middle c complete * 3 tones * cleanup * signal def new line * Add save functionality * Perf improvements, 10x improvement * cleanup * use bitreverse lookup table for performance * implement constant initializers for tensors * small changes * add matmul tests * merge issues * support add attribute * add tests for double data type windowfunctions and minor cleanup * stft onesided/and not tests * cleanup * cleanup * clean up * cleanup * remove threading attribute * forward declare orttypeinfo * warnings * fwd declare * fix warnings * 1 more warning * remove saving to e drive... * cleanup and fix stft test * add opset picker * small additions * add onnxruntime tests * add signed/unsigned * fix warning * fix warning * finish onnxruntime tests * make windows namespace build succeed * add experimental flag * add experimental api into nuget package * add experimental api build flag and add to windows ai nuget package * turn experimental for tests * add minimum opset version to new experimental domain * api cleanup * disable ms experimental ops test when --ms_experimental is not enabled * add macro behind flag * remove unused x * pr feedback Co-authored-by: Sheil Kumar <sheilk@microsoft.com>
69 lines
No EOL
3.5 KiB
C++
69 lines
No EOL
3.5 KiB
C++
#include "pch.h"
|
|
#include "LearningModelInputs.h"
|
|
#include "LearningModelOperator.h"
|
|
#include "LearningModelSession.h"
|
|
#include "LearningModelBuilder.h"
|
|
#include "TensorFeatureDescriptor.h"
|
|
|
|
#include "..\Api\inc\ILotusValueProviderPrivate.h"
|
|
|
|
namespace WINML_EXPERIMENTALP {
|
|
|
|
LearningModelInputs::LearningModelInputs(winml_experimental::LearningModelBuilder builder) : builder_(builder),
|
|
input_descriptors_(winrt::single_threaded_vector<winml::ILearningModelFeatureDescriptor>()),
|
|
input_default_values_(winrt::single_threaded_vector<wf::IInspectable>()),
|
|
constant_descriptors_(winrt::single_threaded_vector<winml::ILearningModelFeatureDescriptor>()),
|
|
constant_values_(winrt::single_threaded_vector<wf::IInspectable>()) {
|
|
}
|
|
|
|
winml_experimental::LearningModelBuilder LearningModelInputs::AddInput(winml::ILearningModelFeatureDescriptor const& input, Windows::Foundation::IInspectable const& default_value, bool is_constant) {
|
|
// Perform model update inside the builder
|
|
auto model = builder_.as<winml_experimentalp::LearningModelBuilder>()->UseModel();
|
|
auto descriptor_provider = input.as<_winml::IDescriptorInfoProvider>();
|
|
auto input_name = _winml::Strings::UTF8FromHString(input.Name());
|
|
winrt::com_ptr<_winml::IValue> default_value_ivalue;
|
|
|
|
if (default_value) {
|
|
auto default_value_value_provider = default_value.as<_winml::ILotusValueProviderPrivate>();
|
|
// Create the Binding Context to pass to the feature value
|
|
_winml::BindingContext context{
|
|
_winml::BindingType::kInput,
|
|
builder_.as<winml_experimentalp::LearningModelBuilder>()->InertSession(),
|
|
nullptr,
|
|
nullptr,
|
|
{} // SubresourceId is set by callee
|
|
};
|
|
default_value_value_provider->GetValue(context, default_value_ivalue.put());
|
|
}
|
|
|
|
model->AddModelInput(input_name.c_str(), descriptor_provider.get(), is_constant, default_value_ivalue.get());
|
|
|
|
return builder_;
|
|
}
|
|
|
|
winml_experimental::LearningModelBuilder LearningModelInputs::Add(winml::ILearningModelFeatureDescriptor const& input) {
|
|
return AddInput(input, nullptr, false);
|
|
}
|
|
|
|
winml_experimental::LearningModelBuilder LearningModelInputs::Add(hstring const& input_name, hstring const& input_description, Windows::Foundation::IInspectable const& default_value) {
|
|
if (auto tensor = default_value.try_as<winml::ITensor>()) {
|
|
auto shape = tensor.Shape();
|
|
std::vector<int64_t> shape_vector(begin(shape), end(shape));
|
|
auto descriptor = winrt::make<winmlp::TensorFeatureDescriptor>(input_name, input_description, tensor.TensorKind(), shape_vector);
|
|
return AddInput(descriptor, default_value, false);
|
|
}
|
|
WINML_THROW_HR(E_UNEXPECTED);
|
|
}
|
|
|
|
winml_experimental::LearningModelBuilder LearningModelInputs::AddConstant(hstring const& input_name, Windows::Foundation::IInspectable const& value) {
|
|
if (auto tensor = value.try_as<winml::ITensor>()) {
|
|
winrt::hstring no_description_for_constants = L"";
|
|
auto shape = tensor.Shape();
|
|
std::vector<int64_t> shape_vector(begin(shape), end(shape));
|
|
auto descriptor = winrt::make<winmlp::TensorFeatureDescriptor>(input_name, no_description_for_constants, tensor.TensorKind(), shape_vector);
|
|
return AddInput(descriptor, value, true);
|
|
}
|
|
WINML_THROW_HR(E_UNEXPECTED);
|
|
}
|
|
|
|
} // namespace WINML_EXPERIMENTALP
|