onnxruntime/onnxruntime/server/util.h
Colin Versteeg a8ff209ab6 Refactor Onnx runtime Server to only use public APIs (#1271)
* replace log sinks

* limit headers to include dir

* first changes to do dynamic linking

* wip for using cxx api

* remove weird dangling dependency

* building with tests failing

* finish updating converters

* fix const

* intital introduction of typedef

* change logging to use spdlog

* get tests passing

* clang format

* map logging levels better

* clean up unused imports

* trent cr comments

* clang-format

* code review comments

* changing buffer use to reserve

* Dynamically link

* revert tvm

* update binary uploading

* catch exceptions by const-ref

* Revert "revert tvm"

This reverts commit 387676dd1018134d15eb71fa126f7caf94380800.

* fix typo

* update versioning of lib
2019-07-04 01:08:14 -07:00

46 lines
1 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <google/protobuf/stubs/status.h>
#include "core/common/status.h"
namespace onnxruntime {
namespace server {
/**
* A RAII container for MLValue buffers
*/
class MemBufferArray {
public:
MemBufferArray() = default;
uint8_t* AllocNewBuffer(size_t tensor_length) {
auto* data = new uint8_t[tensor_length];
memset(data, 0, tensor_length);
buffers_.push_back(data);
return data;
}
~MemBufferArray() {
FreeBuffers();
}
private:
std::vector<uint8_t*> buffers_;
void FreeBuffers() {
for (auto* buf : buffers_) {
delete[] buf;
}
}
};
google::protobuf::util::Status GenerateProtobufStatus(const int& onnx_status, const std::string& message);
// Generate protobuf status from ONNX Runtime status
google::protobuf::util::Status GenerateProtobufStatus(const onnxruntime::common::Status& onnx_status, const std::string& message);
} // namespace server
} // namespace onnxruntime