Skip to content

Commit

Permalink
cpplint code inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhenze Wang committed Nov 23, 2023
1 parent 5d0be84 commit 0e17092
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
20 changes: 11 additions & 9 deletions onnxruntime/core/providers/vitisai/imp/global_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
// Licensed under the MIT License.
#include "vaip/global_api.h"

#include <atomic>
#include <fstream>

#include "./vai_assert.h"
#include "core/common/exceptions.h"
#include "core/common/logging/logging.h"
Expand All @@ -12,8 +16,6 @@
#include "core/session/ort_env.h"
#include "core/session/onnxruntime_cxx_api.h"

#include <atomic>
#include <fstream>
#include <nlohmann/json.hpp>

#include "vaip/dll_safe.h"
Expand Down Expand Up @@ -57,12 +59,12 @@ struct OrtVitisAIEpAPI {
auto full_path = Env::Default().GetRuntimePath() +
PathString(LIBRARY_PREFIX ORT_TSTR("onnxruntime_vitisai_ep") LIBRARY_EXTENSION);
ORT_THROW_IF_ERROR(Env::Default().LoadDynamicLibrary(full_path, true, &handle_));
ORT_THROW_IF_ERROR(Env::Default().GetSymbolFromLibrary(handle_, "initialize_onnxruntime_vitisai_ep",
(void**)&initialize_onnxruntime_vitisai_ep));
ORT_THROW_IF_ERROR(Env::Default().GetSymbolFromLibrary(
handle_, "initialize_onnxruntime_vitisai_ep", reinterpret_cast<void**>(&initialize_onnxruntime_vitisai_ep)));
auto status1 = Env::Default().GetSymbolFromLibrary(handle_, "compile_onnx_model_vitisai_ep_with_options",
(void**)&compile_onnx_model_with_options);
auto status2 =
Env::Default().GetSymbolFromLibrary(handle_, "compile_onnx_model_vitisai_ep", (void**)&compile_onnx_model_3);
reinterpret_cast<void**>(&compile_onnx_model_with_options));
auto status2 = Env::Default().GetSymbolFromLibrary(handle_, "compile_onnx_model_vitisai_ep",
reinterpret_cast<void**>(&compile_onnx_model_3));
if (!status1.IsOK() && !status2.IsOK()) {
::onnxruntime::LogRuntimeError(0, status1, __FILE__, static_cast<const char*>(__FUNCTION__), __LINE__);
ORT_THROW(status1);
Expand Down Expand Up @@ -232,7 +234,7 @@ vaip_core::OrtApiForVaip* create_org_api_hook() {
};
the_global_api.graph_nodes_unsafe = [](const Graph& graph) -> vaip_core::DllSafe<std::vector<const Node*>> {
auto& node_refererence = graph.Nodes();
std::vector<const Node*> nodes((size_t)graph.NumberOfNodes(), nullptr);
std::vector<const Node*> nodes(static_cast<size_t>(graph.NumberOfNodes()), nullptr);
std::transform(node_refererence.begin(), node_refererence.end(), nodes.begin(), [](const Node& n) { return &n; });
return vaip_core::DllSafe(std::move(nodes));
};
Expand All @@ -249,7 +251,7 @@ vaip_core::OrtApiForVaip* create_org_api_hook() {

the_global_api.node_op_type = [](const Node& node) -> const std::string& { return node.OpType(); };
the_global_api.node_op_domain = [](const Node& node) -> const std::string& { return node.Domain(); };
the_global_api.node_get_index = [](const Node& node) -> size_t { return (size_t)node.Index(); };
the_global_api.node_get_index = [](const Node& node) -> size_t { return static_cast<size_t>(node.Index()); };
the_global_api.node_get_name = [](const Node& node) -> const std::string& { return node.Name(); };
the_global_api.node_description = [](const Node& node) -> const std::string& { return node.Description(); };

Expand Down
8 changes: 6 additions & 2 deletions onnxruntime/core/providers/vitisai/include/vaip/global_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <vector>
#include <memory>
#include <string>

#include "core/session/onnxruntime_cxx_api.h"
#include "core/framework/provider_options.h"
#include <vector>
#include "vaip/my_ort.h"
#include "vaip/dll_safe.h"
#include "vaip/custom_op.h"

std::vector<OrtCustomOpDomain*> initialize_vitisai_ep();
vaip_core::DllSafe<std::vector<std::unique_ptr<vaip_core::ExecutionProvider>>> compile_onnx_model_with_options(const std::string& model_path, const onnxruntime::Graph& graph, const onnxruntime::ProviderOptions& options);
vaip_core::DllSafe<std::vector<std::unique_ptr<vaip_core::ExecutionProvider>>> compile_onnx_model_with_options(
const std::string& model_path, const onnxruntime::Graph& graph, const onnxruntime::ProviderOptions& options);
14 changes: 8 additions & 6 deletions onnxruntime/core/providers/vitisai/vitisai_execution_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#pragma once

#include <ctime>
#include <vector>
#include <memory>
#include <set>
#include <string>

#include "core/framework/execution_provider.h"
#include "core/framework/customregistry.h"
Expand All @@ -24,15 +28,13 @@ class VitisAIExecutionProvider : public IExecutionProvider {
explicit VitisAIExecutionProvider(const ProviderOptions& info);
~VitisAIExecutionProvider() = default;

std::vector<std::unique_ptr<ComputeCapability>>
GetCapability(const onnxruntime::GraphViewer& graph,
const IKernelLookup& /*kernel_lookup*/) const override;
std::vector<std::unique_ptr<ComputeCapability>> GetCapability(const onnxruntime::GraphViewer& graph,
const IKernelLookup& /*kernel_lookup*/) const override;

int GetDeviceId() const { return 0; }

common::Status Compile(
const std::vector<FusedNodeAndGraph>& fused_nodes_and_graphs,
std::vector<NodeComputeInfo>& node_compute_funcs) override;
common::Status Compile(const std::vector<FusedNodeAndGraph>& fused_nodes_and_graphs,
std::vector<NodeComputeInfo>& node_compute_funcs) override;
std::shared_ptr<KernelRegistry> GetKernelRegistry() const override;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

#include "vitisai_provider_factory_creator.h"

#include <unordered_map>
#include <string>

#include "vaip/global_api.h"
#include "./vitisai_execution_provider.h"
#include "core/framework/execution_provider.h"

#include "core/session/abi_session_options_impl.h"
#include "core/providers/shared_library/provider_host_api.h"
#include <unordered_map>
#include <string>

using namespace onnxruntime;
namespace onnxruntime {
Expand All @@ -29,7 +30,8 @@ std::unique_ptr<IExecutionProvider> VitisAIProviderFactory::CreateProvider() {
return std::make_unique<VitisAIExecutionProvider>(info_);
}

std::shared_ptr<IExecutionProviderFactory> VitisAIProviderFactoryCreator::Create(const ProviderOptions& provider_options) {
std::shared_ptr<IExecutionProviderFactory> VitisAIProviderFactoryCreator::Create(
const ProviderOptions& provider_options) {
initialize_vitisai_ep();
return std::make_shared<VitisAIProviderFactory>(provider_options);
}
Expand Down

0 comments on commit 0e17092

Please sign in to comment.