@@ -91,6 +91,8 @@ ZeroInferRequest::ZeroInferRequest(const std::shared_ptr<ZeroInitStructsHolder>&
91
91
return std::find (container.begin (), container.end (), value) != container.end ();
92
92
};
93
93
94
+ auto allocator = zeroMemory::HostMemAllocator (backendPtr);
95
+
94
96
for (const std::string& inputName : _metadata.inputNames ) {
95
97
if (!executorInputDescriptors.count (inputName)) {
96
98
OPENVINO_THROW (" Invalid graph input descriptor key: " + inputName);
@@ -99,15 +101,15 @@ ZeroInferRequest::ZeroInferRequest(const std::shared_ptr<ZeroInitStructsHolder>&
99
101
const IONodeDescriptor& parameterDescriptor = _metadata.parameters .at (inputName);
100
102
check_level_zero_attributes_match (parameterDescriptor, executorInputDescriptors.at (inputName), inputName);
101
103
102
- ov::Allocator allocator ;
104
+ ov::Allocator inputAllocator ;
103
105
if (properties.flags & ZE_DEVICE_PROPERTY_FLAG_INTEGRATED) {
104
- allocator = zeroMemory::HostMemAllocator (backendPtr, ZE_HOST_MEM_ALLOC_FLAG_BIAS_WRITE_COMBINED);
106
+ inputAllocator = zeroMemory::HostMemAllocator (backendPtr, ZE_HOST_MEM_ALLOC_FLAG_BIAS_WRITE_COMBINED);
105
107
} else {
106
- allocator = zeroMemory::HostMemAllocator (backendPtr);
107
- }
108
+ inputAllocator = zeroMemory::HostMemAllocator (backendPtr);
109
+ };
108
110
109
111
// The I/O buffers already allocated using the Level Zero API are being reused here
110
- allocate_tensor (inputName, parameterDescriptor, TensorType::InputOrOutput, allocator );
112
+ allocate_tensor (inputName, parameterDescriptor, TensorType::InputOrOutput, inputAllocator );
111
113
112
114
if (contains (_metadata.shapeNames , inputName)) {
113
115
const std::string shapeBufferName = SHAPE_TENSOR_PREFIX + inputName;
@@ -117,8 +119,7 @@ ZeroInferRequest::ZeroInferRequest(const std::shared_ptr<ZeroInitStructsHolder>&
117
119
executorInputDescriptors.at (shapeBufferName),
118
120
shapeBufferName);
119
121
120
- auto allocator = zeroMemory::HostMemAllocator (backendPtr);
121
- allocate_tensor (inputName, shapeDescriptor, TensorType::Shape, allocator);
122
+ allocate_tensor (inputName, shapeDescriptor, TensorType::Shape, inputAllocator);
122
123
}
123
124
}
124
125
@@ -130,20 +131,20 @@ ZeroInferRequest::ZeroInferRequest(const std::shared_ptr<ZeroInitStructsHolder>&
130
131
const IONodeDescriptor& resultDescriptor = _metadata.results .at (outputName);
131
132
check_level_zero_attributes_match (resultDescriptor, executorOutputDescriptors.at (outputName), outputName);
132
133
133
- auto allocator = zeroMemory::HostMemAllocator (backendPtr);
134
-
135
134
allocate_tensor (outputName, resultDescriptor, TensorType::InputOrOutput, allocator);
136
135
137
- if (contains (_metadata.shapeNames , outputName)) {
138
- const std::string shapeBufferName = SHAPE_TENSOR_PREFIX + outputName;
139
- const IONodeDescriptor& shapeDescriptor = _metadata.shapes .at (outputName);
136
+ const auto & shapeNameMatch = _nodeNameToLegacyName.find (outputName);
137
+ if (shapeNameMatch != _nodeNameToLegacyName.end ()) {
138
+ if (contains (_metadata.shapeNames , shapeNameMatch->second )) {
139
+ const std::string shapeBufferName = SHAPE_TENSOR_PREFIX + shapeNameMatch->second ;
140
+ const IONodeDescriptor& shapeDescriptor = _metadata.shapes .at (shapeNameMatch->second );
140
141
141
- check_level_zero_attributes_match (shapeDescriptor,
142
- executorOutputDescriptors.at (shapeBufferName),
143
- shapeBufferName);
142
+ check_level_zero_attributes_match (shapeDescriptor,
143
+ executorOutputDescriptors.at (shapeBufferName),
144
+ shapeBufferName);
144
145
145
- auto allocator = zeroMemory::HostMemAllocator (backendPtr );
146
- allocate_tensor (outputName, shapeDescriptor, TensorType::Shape, allocator);
146
+ allocate_tensor (shapeNameMatch-> second , shapeDescriptor, TensorType::Shape, allocator );
147
+ }
147
148
}
148
149
}
149
150
@@ -166,8 +167,6 @@ ZeroInferRequest::ZeroInferRequest(const std::shared_ptr<ZeroInitStructsHolder>&
166
167
executorOutputDescriptors.at (stateOutputBufferName),
167
168
stateOutputBufferName);
168
169
169
- auto allocator = zeroMemory::HostMemAllocator (backendPtr);
170
-
171
170
// Only one buffer per state variable is required, we'll use the "output" one since this one captures the latest
172
171
// tensor value
173
172
allocate_tensor (stateName, stateDescriptor, TensorType::State, allocator);
@@ -226,15 +225,18 @@ void ZeroInferRequest::get_result() {
226
225
227
226
if (isShapeTensorName (name)) {
228
227
const auto actualTensorName = name.substr (SHAPE_TENSOR_PREFIX.size ());
229
- ov::Shape actualDims;
230
- actualDims.reserve (outputTensor->get_size ());
231
-
232
- for (size_t i = 0 ; i < outputTensor->get_size (); ++i) {
233
- const auto reverseIdx = outputTensor->get_size () - 1 - i;
234
- actualDims.push_back (outputTensor->data <uint32_t >()[reverseIdx]);
228
+ const auto & shapeNameMatch = _legacyNameToNodeName.find (actualTensorName);
229
+ if (shapeNameMatch != _legacyNameToNodeName.end ()) {
230
+ ov::Shape actualDims;
231
+ actualDims.reserve (outputTensor->get_size ());
232
+
233
+ for (size_t i = 0 ; i < outputTensor->get_size (); ++i) {
234
+ const auto reverseIdx = outputTensor->get_size () - 1 - i;
235
+ actualDims.push_back (outputTensor->data <uint32_t >()[reverseIdx]);
236
+ }
237
+ auto & tensorToBeReshaped = _allTensors.at (shapeNameMatch->second );
238
+ tensorToBeReshaped->set_shape (actualDims);
235
239
}
236
- auto & tensorToBeReshaped = _allTensors.at (actualTensorName);
237
- tensorToBeReshaped->set_shape (actualDims);
238
240
}
239
241
240
242
uint8_t * tensorBuffer = reinterpret_cast <uint8_t *>(outputTensor->data ());
0 commit comments