Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions onnxruntime/core/providers/vitisai/imp/graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "vaip/node.h"
#include "vaip/node_arg.h"

#include "./tensor_proto.h"
namespace vaip {

struct NodeEdgeT {
Expand Down Expand Up @@ -309,7 +309,14 @@ Model* model_clone(const Model& original_model, int64_t external_data_threshold)
cloned_tensor->add_dims(dim);
size = size * dim;
}
if (size >= external_data_threshold) {
auto ORT_MEM_ADDR_tag = process_ext_address(*original_tensor);
if (!ORT_MEM_ADDR_tag.empty()) {
cloned_tensor->set_data_location(ONNX_NAMESPACE::TensorProto_DataLocation_EXTERNAL);
auto external_data = cloned_tensor->mutable_external_data();
auto p = external_data->Add();
*p->mutable_key() = "location";
*p->mutable_value() = std::string("<") + graph_ptr;
} else if (size >= external_data_threshold) {
cloned_tensor->set_data_location(ONNX_NAMESPACE::TensorProto_DataLocation_EXTERNAL);
auto external_data = cloned_tensor->mutable_external_data();
auto p = external_data->Add();
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/providers/vitisai/imp/tensor_proto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace vaip {
using namespace onnxruntime;

static gsl::span<const char> process_ext_address(const ONNX_NAMESPACE::TensorProto& tensor) {
gsl::span<const char> process_ext_address(const ONNX_NAMESPACE::TensorProto& tensor) {
auto tensor_proto = const_cast<ONNX_NAMESPACE::TensorProto*>(&tensor);
auto file = std::string();
uintptr_t offset = 0;
Expand Down
1 change: 1 addition & 0 deletions onnxruntime/core/providers/vitisai/imp/tensor_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ ONNX_NAMESPACE::TensorProto* tensor_proto_new_fp16(const std::string& name, cons
const std::vector<int16_t>& data);
ONNX_NAMESPACE::TensorProto* tensor_proto_new_doubles(const std::string& name, const std::vector<int64_t>& shape,
const std::vector<double>& data);
gsl::span<const char> process_ext_address(const ONNX_NAMESPACE::TensorProto& tensor);
} // namespace vaip
Loading