Skip to content

Commit 1756787

Browse files
committed
Rename onnx->ort + remove unused parameter shape functions
1 parent 4f32f22 commit 1756787

File tree

4 files changed

+19
-35
lines changed

4 files changed

+19
-35
lines changed

onnxruntime/core/providers/openvino/backend_utils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ GetOutputTensor(Ort::KernelContext& context,
190190
ORT_THROW(log_tag + "Output names mismatch between OpenVINO and ONNX");
191191
}
192192
int index = it->second;
193-
auto output_shape = ParameterShape::ToOnnxShape(node->get_shape());
193+
auto output_shape = ParameterShape::ToOrtShape(node->get_shape());
194194

195195
return context.GetOutput(index, output_shape);
196196
}

onnxruntime/core/providers/openvino/backends/basic_backend.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ void BasicBackend::Infer(OrtKernelContext* ctx) const {
526526
// Copy outputs
527527
for (const auto& output_info : bindings_->network_outputs_) {
528528
auto ov_tensor = infer_request->GetTensor(output_info.name);
529-
auto output_shape = ParameterShape::ToOnnxShape(ov_tensor->get_shape());
529+
auto output_shape = ParameterShape::ToOrtShape(ov_tensor->get_shape());
530530
auto ort_tensor = context.GetOutput(output_info.onnx_index, output_shape);
531531

532532
memcpy_s(ort_tensor.GetTensorMutableRawData(),
@@ -544,7 +544,7 @@ void BasicBackend::Infer(OrtKernelContext* ctx) const {
544544

545545
// Bind outputs
546546
for (const auto& output_info : bindings_->network_outputs_) {
547-
infer_request->SetTensor(output_info, context.GetOutput(output_info.onnx_index, output_info.shape.onnx()).GetTensorMutableRawData());
547+
infer_request->SetTensor(output_info, context.GetOutput(output_info.onnx_index, output_info.shape.ort()).GetTensorMutableRawData());
548548
}
549549

550550
// Run Inference

onnxruntime/core/providers/openvino/ibackend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace openvino_ep {
1515
class IBackend {
1616
public:
1717
virtual void Infer(OrtKernelContext* context) const = 0;
18-
virtual ov::CompiledModel& GetOVCompiledModel() = 0;
18+
virtual ov::CompiledModel GetOVCompiledModel() = 0;
1919
virtual ~IBackend() = default;
2020
};
2121
using ptr_stream_t = std::unique_ptr<std::istream>;

onnxruntime/core/providers/openvino/ov_interface.h

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,52 +39,36 @@ typedef ov::RemoteContext OVRemoteContext;
3939
#endif
4040

4141
struct ParameterShape {
42-
using onnx_shape_t = std::vector<int64_t>;
42+
using ort_shape_t = std::vector<int64_t>;
4343

44-
private:
45-
onnx_shape_t onnx_;
46-
ov::PartialShape ov_;
47-
48-
public:
49-
static ov::PartialShape ToOvPartialShape(const onnx_shape_t& onnx_shape) {
50-
std::vector<ov::Dimension> ov_shape(onnx_shape.size());
51-
std::transform(onnx_shape.begin(), onnx_shape.end(), ov_shape.begin(), [](int64_t dim) {
44+
static ov::PartialShape ToOvPartialShape(const ort_shape_t& ort_shape) {
45+
std::vector<ov::Dimension> ov_shape(ort_shape.size());
46+
std::transform(ort_shape.begin(), ort_shape.end(), ov_shape.begin(), [](int64_t dim) {
5247
return dim == -1 ? ov::Dimension::dynamic() : ov::Dimension(dim);
5348
});
5449
return ov::PartialShape(ov_shape);
5550
}
5651

57-
static onnx_shape_t ToOnnxShape(const ov::PartialShape& ov_shape) {
58-
onnx_shape_t onnx_shape(ov_shape.size());
59-
std::transform(ov_shape.begin(), ov_shape.end(), onnx_shape.begin(), [](const auto& dim) {
52+
static ort_shape_t ToOrtShape(const ov::PartialShape& ov_shape) {
53+
ort_shape_t ort_shape(ov_shape.size());
54+
std::transform(ov_shape.begin(), ov_shape.end(), ort_shape.begin(), [](const auto& dim) {
6055
return dim.is_dynamic() ? -1 : dim.get_length();
6156
});
62-
return onnx_shape;
63-
}
64-
65-
static bool IsDynamic(const ov::PartialShape& ov_shape) {
66-
return ov_shape.is_dynamic();
67-
}
68-
static bool IsDynamic(const onnx_shape_t& onnx_shape) {
69-
return std::any_of(onnx_shape.begin(), onnx_shape.end(), [](const auto& dim) { return dim == -1; });
57+
return ort_shape;
7058
}
7159

7260
ov::Shape ov_shape() const { return ov_.get_shape(); }
73-
7461
const ov::PartialShape& ov() const { return ov_; }
75-
const onnx_shape_t& onnx() const { return onnx_; }
76-
77-
ParameterShape reshape(const onnx_shape_t& new_onnx_shape) const {
78-
return ParameterShape(new_onnx_shape);
79-
};
80-
ParameterShape reshape(const ov::Shape& new_ov_shape) const {
81-
return ParameterShape(new_ov_shape);
82-
};
62+
const ort_shape_t& ort() const { return ort_; }
8363

84-
ParameterShape(const onnx_shape_t& onnx_shape) : onnx_(onnx_shape), ov_(ToOvPartialShape(onnx_shape)) {
64+
ParameterShape(const ort_shape_t& ort_shape) : ort_(ort_shape), ov_(ToOvPartialShape(ort_shape)) {
8565
}
86-
ParameterShape(const ov::PartialShape& ov_partial_shape) : ov_(ov_partial_shape), onnx_(ToOnnxShape(ov_partial_shape)) {
66+
ParameterShape(const ov::PartialShape& ov_partial_shape) : ov_(ov_partial_shape), ort_(ToOrtShape(ov_partial_shape)) {
8767
}
68+
69+
private:
70+
ort_shape_t ort_;
71+
ov::PartialShape ov_;
8872
};
8973

9074
struct ParameterInfo {

0 commit comments

Comments
 (0)