remove legacy compile api (#12932)

Co-authored-by: Cheng Tang <chenta@microsoft.com@orttrainingdev9.d32nl1ml4oruzj4qz3bqlggovf.px.internal.cloudapp.net>
This commit is contained in:
Tang, Cheng 2022-09-15 13:18:40 -07:00 committed by GitHub
parent 203f63c224
commit 739b5675c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 3 additions and 66 deletions

View file

@ -228,15 +228,6 @@ class IExecutionProvider {
}
#if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
/**
* !!!! This API is deprecated. If your execution provider overrides this API
* !!!! Please migrate it to the "Compile" API with FusedNodeAndGraph type.
Given a list of fused_node, return create_state/compute/release_state func for each node.
*/
virtual common::Status Compile(const std::vector<onnxruntime::Node*>& fused_nodes,
std::vector<NodeComputeInfo>& node_compute_funcs);
/**
Given a collection of fused Nodes and the respective GraphViewer instance for the nodes that were fused,
return create_state/compute/release_state func for each node.

View file

@ -101,14 +101,6 @@ void IExecutionProvider::RegisterAllocator(AllocatorManager&) {
}
#if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
// !!!!This API will be deprecated soon. If your execution provider overrides this API
// !!!!Please migrate it to the "Compile" API with FusedNodeAndGraph type.
common::Status IExecutionProvider::Compile(const std::vector<onnxruntime::Node*>& /*fused_node*/,
std::vector<NodeComputeInfo>& /*node_compute_funcs*/) {
return common::Status(common::ONNXRUNTIME, common::NOT_IMPLEMENTED,
"IExecutionProvider::Compile with fused Node is not implemented by " + type_);
}
common::Status IExecutionProvider::Compile(const std::vector<FusedNodeAndGraph>& /*fused_nodes_and_graphs*/,
std::vector<NodeComputeInfo>& /*node_compute_funcs*/) {
return common::Status(common::ONNXRUNTIME, common::NOT_IMPLEMENTED,

View file

@ -42,15 +42,6 @@ NonCudaOps non_cuda;
using namespace ::onnxruntime::common;
namespace onnxruntime {
#if !defined(ORT_MINIMAL_BUILD)
static void BuildFusedKernelDef(KernelDefBuilder& builder, const onnxruntime::Node& node) {
auto schema = node.Op();
builder.SetName(schema->Name())
.SetDomain(schema->domain())
.SinceVersion(schema->SinceVersion())
.Provider(node.GetExecutionProviderType());
}
#endif
// minimal KernelDef based on MetaDef instead of a Function based node
static void BuildFusedKernelDef(KernelDefBuilder& builder, const IndexedSubGraph::MetaDef& metadef,
@ -371,33 +362,7 @@ static Status PartitionOnnxFormatModelImpl(Graph& graph, FuncManager& func_mgr,
// !!! The Function style fusion is deprecated.
if (fusion_style == IExecutionProvider::FusionStyle::Function) {
// Create a Function based node where the fused nodes have a new Graph instance.
static std::once_flag legacy_compile_method_warning_flag;
std::call_once(
legacy_compile_method_warning_flag, [](std::string_view ep_type) {
LOGS_DEFAULT(WARNING) << "Execution Provider: " << ep_type << " is still using Function style Compile API "
"which is deprecated and will be removed soon. Please migrate to the new Compile "
"API based on FilteredGraphViewer.";
},
type);
ORT_RETURN_IF_ERROR(current_ep.Compile(nodes_to_compile, node_compute_funcs));
if (node_compute_funcs.size() != nodes_to_compile.size()) {
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, type, " did not return correct number of compiled functions");
}
for (size_t j = 0, end = nodes_to_compile.size(); j < end; j++) {
ORT_RETURN_IF_ERROR(func_mgr.AddFuncInfo(nodes_to_compile[j]->Name(), std::move(node_compute_funcs[j])));
}
for (auto* node : nodes_to_compile) {
// add the KernelDef instances for the compiled nodes
KernelDefBuilder builder;
BuildFusedKernelDef(builder, *node);
ORT_RETURN_IF_ERROR(fused_kernel_registry.Register(builder,
[](FuncManager& func_mgr, const OpKernelInfo& info, std::unique_ptr<OpKernel>& out) -> Status {
return FunctionKernel::Create(func_mgr, info, out);
}));
}
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, type, "The Function Style fusion is deprecated.");
} else {
// temporary storage for the GraphViewer for each IndexedSubGraph
std::vector<std::unique_ptr<GraphViewer>> viewers;

View file

@ -291,11 +291,6 @@ std::vector<std::unique_ptr<ComputeCapability>> IExecutionProvider::GetCapabilit
const std::vector<const KernelRegistry*>& kernel_registries) const {
return g_host->IExecutionProvider__GetCapability(this, graph_viewer, kernel_registries);
}
// !!! This API will be deprecated soon.
common::Status IExecutionProvider::Compile(const std::vector<onnxruntime::Node*>& fused_nodes,
std::vector<NodeComputeInfo>& node_compute_funcs) {
return g_host->IExecutionProvider__Compile(this, fused_nodes, node_compute_funcs);
}
common::Status IExecutionProvider::Compile(const std::vector<FusedNodeAndGraph>& fused_nodes_and_graphs,
std::vector<NodeComputeInfo>& node_compute_funcs) {
return g_host->IExecutionProvider__Compile(this, fused_nodes_and_graphs, node_compute_funcs);

View file

@ -225,8 +225,6 @@ struct ProviderHost {
virtual void IExecutionProvider__InsertAllocator(IExecutionProvider* p, AllocatorPtr allocator) = 0;
virtual std::vector<std::unique_ptr<ComputeCapability>> IExecutionProvider__GetCapability(const IExecutionProvider* p, const onnxruntime::GraphViewer& graph_viewer,
const std::vector<const KernelRegistry*>& kernel_registries) = 0;
//!!! This API will be deprecated soon
virtual common::Status IExecutionProvider__Compile(IExecutionProvider* p, const std::vector<onnxruntime::Node*>& fused_nodes, std::vector<NodeComputeInfo>& node_compute_funcs) = 0;
virtual common::Status IExecutionProvider__Compile(IExecutionProvider* p, const std::vector<IExecutionProvider::FusedNodeAndGraph>& fused_nodes_and_graphs, std::vector<NodeComputeInfo>& node_compute_funcs) = 0;

View file

@ -280,10 +280,6 @@ struct ProviderHostImpl : ProviderHost {
void IExecutionProvider__InsertAllocator(IExecutionProvider* p, AllocatorPtr allocator) override { return p->IExecutionProvider::InsertAllocator(allocator); }
std::vector<std::unique_ptr<ComputeCapability>> IExecutionProvider__GetCapability(const IExecutionProvider* p, const onnxruntime::GraphViewer& graph_viewer,
const std::vector<const KernelRegistry*>& kernel_registries) override { return p->IExecutionProvider::GetCapability(graph_viewer, kernel_registries); }
// !!! this api will be deprecated soon
common::Status IExecutionProvider__Compile(IExecutionProvider* p, const std::vector<onnxruntime::Node*>& fused_nodes, std::vector<NodeComputeInfo>& node_compute_funcs) override {
return p->IExecutionProvider::Compile(fused_nodes, node_compute_funcs);
}
common::Status IExecutionProvider__Compile(IExecutionProvider* p, const std::vector<IExecutionProvider::FusedNodeAndGraph>& fused_nodes_and_graphs, std::vector<NodeComputeInfo>& node_compute_funcs) override {
return p->IExecutionProvider::Compile(fused_nodes_and_graphs, node_compute_funcs);
@ -446,7 +442,7 @@ struct ProviderHostImpl : ProviderHost {
std::unique_ptr<ONNX_NAMESPACE::NodeProto> NodeProto__construct() override { return std::make_unique<ONNX_NAMESPACE::NodeProto>(); }
void NodeProto__operator_delete(ONNX_NAMESPACE::NodeProto* p) override { delete p; }
void NodeProto__operator_assign(ONNX_NAMESPACE::NodeProto* p, const ONNX_NAMESPACE::NodeProto& v) override { *p = v; }
int NodeProto__attribute_size(ONNX_NAMESPACE::NodeProto* p) override { return p->attribute_size();}
int NodeProto__attribute_size(ONNX_NAMESPACE::NodeProto* p) override { return p->attribute_size(); }
const ONNX_NAMESPACE::AttributeProto& NodeProto__attribute(const ONNX_NAMESPACE::NodeProto* p, int index) const override { return p->attribute(index); }
// TensorProto (wrapped)
@ -768,7 +764,7 @@ struct ProviderHostImpl : ProviderHost {
IOnnxRuntimeOpSchemaRegistryList({graph_viewer->GetSchemaRegistry()}), graph_viewer->DomainToVersionMap(),
#else
IOnnxRuntimeOpSchemaRegistryList(), graph_viewer->DomainToVersionMap(),
#endif // ORT_MINIMAL_BUILD
#endif // ORT_MINIMAL_BUILD
std::vector<ONNX_NAMESPACE::FunctionProto>(), logger);
}