mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-08 00:23:03 +00:00
* Expose load tensor proto from protobuf file function * Add comment * Remove use of fstream and use parsefromzerocopystream * Close file descriptor after finish parsing it * Close input stream too * Set Close on delete only, no need to close file descriptor * Revert "Set Close on delete only, no need to close file descriptor" This reverts commit5ba6e3c31b. * Revert "Close input stream too" This reverts commit4564776733. * Revert "Close file descriptor after finish parsing it" This reverts commit846e550c4f. * Revert "Remove use of fstream and use parsefromzerocopystream" This reverts commit25a3117183.
27 lines
1,019 B
C++
27 lines
1,019 B
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#pragma once
|
|
|
|
#include "std.h"
|
|
#include "winrt_headers.h"
|
|
#pragma warning(push)
|
|
#pragma warning(disable : 4100)
|
|
#include "onnx/onnx-ml.pb.h"
|
|
#pragma warning(pop)
|
|
namespace ProtobufHelpers
|
|
{
|
|
// LoadTensorFromProtobufFile take a path to a FP32 data file and loads it into a 32bit array or
|
|
// 16bit array based on isFp16
|
|
winml::ITensor LoadTensorFromProtobufFile(const std::wstring& filePath, bool isFp16);
|
|
// LoadTensorFloat16FromProtobufFile takes a path to a FP16 data file and loads it into a 16bit array
|
|
winml::TensorFloat16Bit LoadTensorFloat16FromProtobufFile(const std::wstring& filePath);
|
|
|
|
winml::LearningModel CreateModel(
|
|
winml::TensorKind kind,
|
|
const std::vector<int64_t>& shape,
|
|
uint32_t num_elements = 1);
|
|
|
|
// Populates TensorProto with tensor from protobuf file
|
|
bool LoadOnnxTensorFromProtobufFile(onnx::TensorProto& tensor, std::wstring filePath);
|
|
}
|