@@ -39,52 +39,36 @@ typedef ov::RemoteContext OVRemoteContext;
39
39
#endif
40
40
41
41
struct ParameterShape {
42
- using onnx_shape_t = std::vector<int64_t >;
42
+ using ort_shape_t = std::vector<int64_t >;
43
43
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) {
52
47
return dim == -1 ? ov::Dimension::dynamic () : ov::Dimension (dim);
53
48
});
54
49
return ov::PartialShape (ov_shape);
55
50
}
56
51
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) {
60
55
return dim.is_dynamic () ? -1 : dim.get_length ();
61
56
});
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;
70
58
}
71
59
72
60
ov::Shape ov_shape () const { return ov_.get_shape (); }
73
-
74
61
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_; }
83
63
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 )) {
85
65
}
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)) {
87
67
}
68
+
69
+ private:
70
+ ort_shape_t ort_;
71
+ ov::PartialShape ov_;
88
72
};
89
73
90
74
struct ParameterInfo {
0 commit comments