1
+ // Copyright (C) 2018-2024 Intel Corporation
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ //
4
+
5
+ #pragma once
6
+
7
+ #include " openvino/runtime/common.hpp"
8
+
9
+ // #include "itensor.hpp"
10
+ // #include "shape.hpp"
11
+
12
+ namespace ov {
13
+ // namespace one_plugin {
14
+
15
+ class OPENVINO_RUNTIME_API ITensorDesc : public std::enable_shared_from_this<ITensorDesc> {
16
+ public:
17
+ // ITensorDescType getType() const {
18
+ // return type;
19
+ // }
20
+
21
+ // const ov::Shape& get_shape() const {
22
+ // return shape;
23
+ // }
24
+
25
+ virtual ~ITensorDesc () = default ;
26
+
27
+ // virtual ov::element::Type getPrecision() const = 0;
28
+
29
+ // virtual ITensorDescPtr clone() const = 0;
30
+
31
+ // /**
32
+ // * @brief Returns the offset to the current memory block
33
+ // *
34
+ // * @return offset
35
+ // */
36
+ // virtual size_t getOffsetPadding() const = 0;
37
+
38
+ // /**
39
+ // * @brief Clone descriptor with new dims.
40
+ // * Throws an exception if relaxedCheck is false and some of the new dims conflicts with the internal shape (i.e.
41
+ // its
42
+ // * defined dims ,rank, upper bounds) or if internal shape and dims have different ranks
43
+ // * @param dims new dims
44
+ // * @param relaxedCheck flag which defined must we check dims with internal desc on compatibility
45
+ // * @return ITensorDescPtr with new dims
46
+ // */
47
+ // ITensorDescPtr cloneWithNewDims(const VectorDims& dims, bool relaxedCheck = false) const {
48
+ // if (relaxedCheck) {
49
+ // if (getShape().getRank() != dims.size()) {
50
+ // OPENVINO_THROW("ParameterMismatch: Can not clone with new dims, ranks mistmatch. Descriptor's rank:
51
+ // ",
52
+ // getShape().getRank(),
53
+ // " is incompatible with provided rank of dimensions: ",
54
+ // dims.size(),
55
+ // ".");
56
+ // }
57
+ // } else if (!getShape().isCompatible(dims)) {
58
+ // OPENVINO_THROW("ParameterMismatch: Can not clone with new dims. Descriptor's shape: ",
59
+ // getShape().toString(),
60
+ // " is incompatible with provided dimensions: ",
61
+ // dims2str(dims),
62
+ // ".");
63
+ // }
64
+
65
+ // return cloneWithNewDimsImp(dims);
66
+ // }
67
+
68
+ // virtual ITensorDescPtr cloneWithNewPrecision(const ov::element::Type prec) const = 0;
69
+
70
+ // virtual bool isCompatible(const ITensorDesc& rhs) const = 0;
71
+
72
+ // // Checks that all dimensions, offsets, strides, etc are defined (!= UNDEFINED_DIM)
73
+ // bool isDefined() const {
74
+ // if (descStatus::Unknown == status) {
75
+ // status = isDefinedImp() ? descStatus::Defined : descStatus::Undefined;
76
+ // }
77
+ // return descStatus::Defined == status;
78
+ // }
79
+
80
+ // virtual bool hasLayoutType(LayoutType layoutType) const = 0;
81
+
82
+ // virtual std::string serializeFormat() const = 0;
83
+
84
+ // // Get memory upper bound if possible. Can be undefined
85
+ // virtual size_t getMaxMemSize() const = 0;
86
+
87
+ // /**
88
+ // * @brief Get minimal required memory size in bytes.
89
+ // * @return return minimal required memory size in bytes or UNDEFINED_SIZE in case undefined descriptor
90
+ // */
91
+ // size_t getCurrentMemSize() const {
92
+ // size_t retVal = UNDEFINED_SIZE;
93
+ // if (canComputeMemSize()) {
94
+ // retVal = getCurrentMemSizeImp();
95
+ // }
96
+ // return retVal;
97
+ // }
98
+
99
+ // bool hasDefinedMaxSize() const {
100
+ // return getMaxMemSize() != ITensorDesc::UNDEFINED_SIZE;
101
+ // }
102
+
103
+ // bool empty() const {
104
+ // return type == Empty;
105
+ // }
106
+
107
+ // template <typename T,
108
+ // typename std::enable_if<!std::is_pointer<T>::value && !std::is_reference<T>::value, int>::type = 0,
109
+ // typename std::enable_if<std::is_base_of<ITensorDesc, T>::value, int>::type = 0>
110
+ // T* as() {
111
+ // T* casted = dynamic_cast<T*>(this);
112
+ // if (!casted)
113
+ // OPENVINO_THROW("Cannot dynamically cast ITensorDesc");
114
+ // return casted;
115
+ // }
116
+
117
+ // template <typename T,
118
+ // typename std::enable_if<!std::is_pointer<T>::value && !std::is_reference<T>::value, int>::type = 0,
119
+ // typename std::enable_if<std::is_base_of<ITensorDesc, T>::value, int>::type = 0>
120
+ // const T* as() const {
121
+ // const T* casted = dynamic_cast<const T*>(this);
122
+ // if (!casted)
123
+ // OPENVINO_THROW("Cannot dynamically cast ITensorDesc");
124
+ // return casted;
125
+ // }
126
+
127
+ // static constexpr size_t UNDEFINED_SIZE = std::numeric_limits<size_t>::max();
128
+
129
+ // protected:
130
+ // ITensorDesc() : type(ITensorDescType::Undef) {}
131
+ // ITensorDesc(Shape shape, ITensorDescType type) : type(type), shape(std::move(shape)) {}
132
+
133
+ // ITensorDesc(const VectorDims& dims, ITensorDescType type) : type(type), shape(dims) {}
134
+
135
+ // virtual void setPrecision(ov::element::Type prc) = 0;
136
+
137
+ // virtual size_t getCurrentMemSizeImp() const = 0;
138
+
139
+ // // Get offset to the n'th element. Returns physical index of the element by the logical one considering padding,
140
+ // // layout, blocking etc.
141
+ // virtual size_t getElementOffset(size_t elemNumber) const = 0;
142
+
143
+ // virtual bool canComputeMemSizeZeroDims() const = 0;
144
+ // virtual bool isDefinedImp() const = 0;
145
+
146
+ // bool canComputeMemSize() const {
147
+ // return isDefined() || canComputeMemSizeZeroDims();
148
+ // }
149
+
150
+ // virtual ITensorDescPtr cloneWithNewDimsImp(const VectorDims& dims) const = 0;
151
+
152
+ // ITensorDescType type;
153
+ // Shape shape;
154
+
155
+ // mutable enum class descStatus : uint8_t {
156
+ // Unknown,
157
+ // Defined,
158
+ // Undefined,
159
+ // } status = descStatus::Unknown;
160
+ };
161
+
162
+ // } // namespace one_plugin
163
+ } // namespace ov
0 commit comments