mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-25 19:48:11 +00:00
### Description ExecutionProvider API refactor - replace OrtMemoryInfo with OrtDevice ### Motivation and Context Currently “Location” is represented as ORTMemoryInfo, which is OrtDevice + OrtMemType, while OrtDevice is represent as DeviceType + DeviceId + MemType. As we can see there is some unnecessary hierarchy, the proposal is to make it a clear definition that to use OrtDevice as an abstraction for Location --------- Co-authored-by: Lei Cao <leca@microsoft.com>
48 lines
1.8 KiB
C++
48 lines
1.8 KiB
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "core/common/status.h"
|
|
#include "core/framework/framework_common.h"
|
|
#include "core/framework/ort_value.h"
|
|
|
|
struct OrtValue;
|
|
namespace onnxruntime {
|
|
class SessionState;
|
|
class TensorShape;
|
|
namespace logging {
|
|
class Logger;
|
|
}
|
|
|
|
class IExecutor {
|
|
public:
|
|
using CustomAllocator = std::function<Status(const TensorShape&, const OrtDevice&, OrtValue&, bool& allocated)>;
|
|
|
|
virtual ~IExecutor() = default;
|
|
|
|
/**
|
|
* The lifetime of 'fetches' is limited by 'session_state'
|
|
*/
|
|
common::Status Execute(const SessionState& session_state,
|
|
gsl::span<const int> feed_mlvalue_idxs,
|
|
gsl::span<const OrtValue> feeds,
|
|
gsl::span<const int> fetch_mlvalue_idxs,
|
|
std::vector<OrtValue>& fetches,
|
|
const logging::Logger& logger) {
|
|
std::unordered_map<size_t, CustomAllocator> fetch_allocators;
|
|
return Execute(session_state, feed_mlvalue_idxs, feeds, fetch_mlvalue_idxs, fetches, fetch_allocators, logger);
|
|
}
|
|
|
|
// TODO: as fetch_allocators is optional, it should be a pointer instead of reference
|
|
virtual common::Status Execute(const SessionState& session_state, gsl::span<const int> feed_mlvalue_idxs,
|
|
gsl::span<const OrtValue> feeds, gsl::span<const int> fetch_mlvalue_idxs,
|
|
std::vector<OrtValue>& fetches,
|
|
// optional custom allocators. key is index in fetches
|
|
const std::unordered_map<size_t, CustomAllocator>& fetch_allocators,
|
|
const logging::Logger& logger) = 0;
|
|
};
|
|
} // namespace onnxruntime
|