-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP]EP interface #18090
base: main
Are you sure you want to change the base?
[WIP]EP interface #18090
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lintrunner found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
import numpy | ||
|
||
import onnxruntime | ||
from onnxruntime.capi import _pybind_state as C |
Check notice
Code scanning / CodeQL
Unused import Note test
|
||
import onnxruntime | ||
from onnxruntime.capi import _pybind_state as C | ||
from onnxruntime.capi.onnxruntime_pybind11_state import RunOptions |
Check notice
Code scanning / CodeQL
Unused import Note test
import numpy | ||
|
||
import onnxruntime | ||
from onnxruntime.capi import _pybind_state as C |
Check notice
Code scanning / CodeQL
Unused import Note test
|
||
import onnxruntime | ||
from onnxruntime.capi import _pybind_state as C | ||
from onnxruntime.capi.onnxruntime_pybind11_state import RunOptions |
Check notice
Code scanning / CodeQL
Unused import Note test
import numpy | ||
|
||
import onnxruntime | ||
from onnxruntime.capi import _pybind_state as C |
Check notice
Code scanning / CodeQL
Unused import Note test
|
||
import onnxruntime | ||
from onnxruntime.capi import _pybind_state as C | ||
from onnxruntime.capi.onnxruntime_pybind11_state import RunOptions |
Check notice
Code scanning / CodeQL
Unused import Note test
|
||
/////////////////////////////////////////////////// Ep Interface /////////////////////////////////////////////////// | ||
|
||
struct IExecutionProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is some dup code here, especially this class, which I have moved to include/onnxruntime/interface/provider/provider.h and renamed as ExecutionProvider #Resolved
using ArgPtrs = std::vector<ArgPtr>; | ||
|
||
template <typename T> | ||
struct ITensor : public IArg { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you going to move this class to interface/framework/Tensor.h?
Shall we consolidate this tensor interface with the one in interface/graph/graph.h ?
namespace onnxruntime { | ||
class OpKernelContext; | ||
} | ||
#endif | ||
|
||
#include "interface/framework/kernel.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to include kernel.h here? I don't see any class declared in kernel.h in the changes of this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably shouldn't include interface/kernel here, as this file is for the internal kernel impl
@@ -9,6 +9,7 @@ | |||
#include "core/framework/op_node_proto_helper.h" | |||
#include "core/graph/graph_viewer.h" | |||
#include "core/common/gsl.h" | |||
#include "interface/framework/kernel.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to include kernel.h here?
|
||
namespace interface { | ||
|
||
enum TensorDataType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume I need to move DataType enum in interface/graph/graph.h here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use the same DataType definition for all the interface.
struct Celu { | ||
Celu(const interface::IKernelInfo&) {} | ||
onnxruntime::Status Compute(onnxruntime::interface::TensorView<float>& input, | ||
onnxruntime::interface::Tensor<float>& output) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this Compute function doing this algorithm of Celu?
max(0,x) + min(0,alpha*(exp(x/alpha)-1))
My understanding is that it is executing max(0, identity(input)), and alpha is not used
struct Celu { | ||
Celu(const interface::IKernelInfo&) {} | ||
onnxruntime::Status Compute(onnxruntime::interface::TensorView<float>& input, | ||
onnxruntime::interface::Tensor<float>& output) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use the interface (interface::ITensor) or the implementation (interface::Tensor) as the parameter?
using ArgPtr = std::unique_ptr<IArg>; | ||
using ArgPtrs = std::vector<ArgPtr>; | ||
|
||
struct ITensor : public IArg { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…nxruntime into rashuai/EpInterface
…nxruntime into rashuai/EpInterface
openvino_ep::BackendManager::GetGlobalContext().onnx_model_path_name = std::string(onnx_path.begin(), onnx_path.end()); | ||
#else | ||
openvino_ep::BackendManager::GetGlobalContext().onnx_model_path_name = graph_viewer.ModelPath().ToPathString(); | ||
openvino_ep::BackendManager::GetGlobalContext().onnx_model_path_name = graph_viewer->ModelPath(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onnx_model_path_name is not used so remove the ModelPath() API
… existing OpenVINO EP factory
…nxruntime into rashuai/EpInterface
#include <vector> | ||
#ifdef INTREE_EP | ||
#include "onnx/onnx_pb.h" | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we find a way to keep the To-Model-Proto onnx API internally under core?
/// <summary> | ||
/// Enum of DataTypes using standard ONNX values. Casting to/from int32_t is encouraged. | ||
/// </summary> | ||
enum class DataType : int32_t { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct ModelProtoPtr { | ||
const char* p; | ||
size_t len; | ||
size_t version; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//#include "core/session/onnxruntime_c_api.h" | ||
#include "core/framework/ortdevice.h" | ||
#include "core/framework/stream_handles.h" | ||
#include "core/framework/node_compute_info.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's carefully review the included headers. if those are the headers we are going to include (with header-only implementation), let's think about how to structure the include folders to represent the depenency.
#include <utility> | ||
#include <vector> | ||
|
||
#include "core/common/code_location.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#pragma once | ||
|
||
#include "core/common/common_no_ort_symbol.h" | ||
#include "core/session/onnxruntime_c_api.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need CAPI?
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file looks weird, it doesn't contain anything with Allocator, but named with allocator...
@@ -68,8 +69,8 @@ struct OpenVINOExecutionProviderInfo { | |||
bool enable_dynamic_shapes) | |||
: enable_vpu_fast_compile_(enable_vpu_fast_compile), device_id_(dev_id), num_of_threads_(num_of_threads), cache_dir_(cache_dir), num_streams_(num_streams), context_(context), enable_opencl_throttling_(enable_opencl_throttling), enable_dynamic_shapes_(enable_dynamic_shapes) { | |||
if (dev_type == "") { | |||
LOGS_DEFAULT(INFO) << "[OpenVINO-EP]" | |||
<< "No runtime device selection option provided."; | |||
//LOGS_DEFAULT(INFO) << "[OpenVINO-EP]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const void* GetExecutionHandle() const noexcept override { | ||
return nullptr; | ||
} | ||
void RegisterKernels(interface::IKernelRegistry&) override {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -8,6 +8,7 @@ | |||
#include "contexts.h" | |||
#include <iomanip> | |||
#include "ov_interface.h" | |||
#include "onnx/onnx_pb.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#else | ||
ORT_UNUSED_PARAMETER(fused_node); | ||
ORT_UNUSED_PARAMETER(subgraph); | ||
return nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so for out of tree case, we just return nullptr? how could it work?
@@ -44,7 +43,7 @@ BasicBackend::BasicBackend(const ONNX_NAMESPACE::ModelProto& model_proto, | |||
if (IsDebugEnabled()) { | |||
std::string file_name = subgraph_context.subgraph_name + "_static.onnx"; | |||
std::fstream outfile(file_name, std::ios::out | std::ios::trunc | std::ios::binary); | |||
model_proto.SerializeToOstream(outfile); | |||
model_proto.SerializeToOstream(&outfile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
01b3cee
to
33a60f5
Compare
WIP...