telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | #include "WorkloadData.hpp" |
| 6 | |
| 7 | #include "CpuTensorHandle.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8 | |
Matteo Martincigh | 2135015 | 2018-11-28 16:22:22 +0000 | [diff] [blame] | 9 | #include <DataLayoutIndexed.hpp> |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 10 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 11 | #include <algorithm> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 12 | #include <iomanip> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 13 | #include <string> |
| 14 | #include <sstream> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | |
| 16 | #include <boost/format.hpp> |
| 17 | |
Matteo Martincigh | 2135015 | 2018-11-28 16:22:22 +0000 | [diff] [blame] | 18 | using namespace armnnUtils; |
| 19 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 20 | namespace armnn |
| 21 | { |
| 22 | |
| 23 | //--------------------------------------------------------------- |
| 24 | DataType GetBiasDataType(DataType inputDataType) |
| 25 | { |
| 26 | switch (inputDataType) |
| 27 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 28 | case DataType::Float16: |
| 29 | return DataType::Float16; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 30 | case DataType::Float32: |
| 31 | return DataType::Float32; |
| 32 | case DataType::QuantisedAsymm8: |
| 33 | return DataType::Signed32; |
| 34 | default: |
| 35 | BOOST_ASSERT_MSG(false, "Invalid input data type"); |
| 36 | return DataType::Float32; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | namespace |
| 41 | { |
| 42 | |
| 43 | //--------------------------------------------------------------- |
| 44 | //android ndk does not support std::to_string function. |
| 45 | template <typename T> |
| 46 | std::string to_string(T value) |
| 47 | { |
| 48 | std::ostringstream os; |
| 49 | os << value; |
| 50 | return os.str(); |
| 51 | } |
| 52 | |
| 53 | //--------------------------------------------------------------- |
| 54 | void ValidatePointer(const void* ptr, std::string const& descName, std::string const& paramName) |
| 55 | { |
| 56 | if (!ptr) |
| 57 | { |
| 58 | throw InvalidArgumentException(descName + ": Invalid null pointer. The " + |
| 59 | paramName + " parameter must be set."); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | //--------------------------------------------------------------- |
| 64 | void ValidateTensorShapesMatch(const TensorInfo& first, |
| 65 | const TensorInfo& second, |
| 66 | std::string const& descName, |
| 67 | std::string const& firstName, |
| 68 | std::string const& secondName) |
| 69 | { |
| 70 | if (first.GetShape() != second.GetShape()) |
| 71 | { |
| 72 | throw InvalidArgumentException(descName + ": " |
| 73 | + firstName + " & " + secondName + " must have identical shapes"); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | //--------------------------------------------------------------- |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 78 | void ValidateNumInputs(const WorkloadInfo& workloadInfo, std::string const& descName, const unsigned int expectedSize) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 79 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 80 | if (workloadInfo.m_InputTensorInfos.size() != expectedSize) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 81 | { |
| 82 | throw InvalidArgumentException(descName + |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 83 | ": Requires exactly " + to_string(expectedSize) + "input(s). " + |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 84 | to_string(workloadInfo.m_InputTensorInfos.size()) + " have been provided."); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | //--------------------------------------------------------------- |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 89 | void ValidateNumOutputs(const WorkloadInfo& workloadInfo, std::string const& descName, const unsigned int expectedSize) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 90 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 91 | if (workloadInfo.m_OutputTensorInfos.size() != expectedSize) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 92 | { |
| 93 | throw InvalidArgumentException(descName + |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 94 | ": Requires exactly " + to_string(expectedSize) + " output(s). " + |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 95 | to_string(workloadInfo.m_OutputTensorInfos.size()) + " has been provided."); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | //--------------------------------------------------------------- |
| 100 | void ValidateTensorNumDimensions(const TensorInfo& tensor, |
| 101 | std::string const& descName, |
| 102 | unsigned int numDimensions, |
| 103 | std::string const& tensorName) |
| 104 | { |
| 105 | if (tensor.GetNumDimensions() != numDimensions) |
| 106 | { |
| 107 | throw InvalidArgumentException(descName + ": Expected " + to_string(numDimensions) + " but got " + |
| 108 | to_string(tensor.GetNumDimensions()) + " dimensions for " + |
| 109 | tensorName + " tensor."); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | //--------------------------------------------------------------- |
| 114 | void ValidateTensorDataType(const TensorInfo& tensor, DataType dataType, |
| 115 | const std::string& descName, std::string const& tensorName) |
| 116 | { |
| 117 | if (tensor.GetDataType() != dataType) |
| 118 | { |
| 119 | throw InvalidArgumentException(descName + ": Expected data type " + GetDataTypeName(dataType) + " but got " + |
| 120 | GetDataTypeName(tensor.GetDataType()) + " for " + tensorName + " tensor."); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | //--------------------------------------------------------------- |
| 125 | void ValidateBiasTensorQuantization(const TensorInfo& biasTensor, const TensorInfo& inputTensorInfo, |
| 126 | const TensorInfo& weightsTensorInfo, const std::string& descName) |
| 127 | { |
| 128 | if (biasTensor.GetQuantizationOffset() != 0) |
| 129 | { |
| 130 | throw InvalidArgumentException(descName + ": Expected zero quantization offset for bias tensor but got " + |
| 131 | to_string(biasTensor.GetQuantizationOffset())); |
| 132 | } |
| 133 | const float expectedScale = inputTensorInfo.GetQuantizationScale() * weightsTensorInfo.GetQuantizationScale(); |
kevmay01 | 6c46dd3 | 2018-12-17 15:32:45 +0000 | [diff] [blame] | 134 | if (std::abs(biasTensor.GetQuantizationScale() - expectedScale) > 0.00000001f) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 135 | { |
| 136 | // Print the float values with extra precision to see very small differences |
| 137 | std::stringstream msg; |
| 138 | msg << std::setprecision(10) << descName << ": Expected " << expectedScale << |
| 139 | " quantization scale for bias tensor (the product of the input and weight scales), but got " << |
| 140 | biasTensor.GetQuantizationScale(); |
| 141 | throw InvalidArgumentException(msg.str()); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | //--------------------------------------------------------------- |
| 146 | void ValidateTensors(const std::vector<ITensorHandle*>& vec, |
| 147 | unsigned int numExpected, |
| 148 | const std::string& descName, |
| 149 | const std::string& varName) |
| 150 | { |
| 151 | if (vec.empty() && numExpected > 0) |
| 152 | { |
| 153 | throw InvalidArgumentException(descName + ": Invalid empty " + varName + " array."); |
| 154 | } |
| 155 | |
| 156 | for (unsigned int i = 0; i < numExpected; ++i) |
| 157 | { |
| 158 | if (!vec[i]) |
| 159 | { |
| 160 | throw InvalidArgumentException(descName + ": Invalid NULL for " + varName + to_string(i)); |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | //--------------------------------------------------------------- |
| 166 | void ValidateBroadcastTensorShapesMatch(const TensorInfo& first, |
| 167 | const TensorInfo& second, |
| 168 | const TensorInfo& output, |
| 169 | std::string const& descName, |
| 170 | std::string const& firstName, |
| 171 | std::string const& secondName) |
| 172 | { |
| 173 | // Tensors must have the same number of dimensions in order to be explicit about which dimensions will get |
| 174 | // broadcasted. |
| 175 | if (first.GetNumDimensions() != second.GetNumDimensions()) |
| 176 | { |
| 177 | throw InvalidArgumentException(descName + ": Tensors " |
| 178 | + firstName + " & " + secondName |
| 179 | + " must have the same number of dimensions in order to be broadcasted"); |
| 180 | } |
| 181 | uint32_t numDims = first.GetNumDimensions(); |
| 182 | std::vector<uint32_t> outputDims(numDims, 0u); |
| 183 | for (uint32_t i = 0; i < numDims; i++) |
| 184 | { |
| 185 | const bool dimsNotEqual = first.GetShape()[i] != second.GetShape()[i]; |
| 186 | const bool dimsNotOne = (first.GetShape()[i] != 1) && (second.GetShape()[i] != 1); |
| 187 | if (dimsNotEqual && dimsNotOne) |
| 188 | { |
| 189 | throw InvalidArgumentException("Broadcasting is not possible for incompatible shapes"); |
| 190 | } |
| 191 | outputDims[i] = std::max(first.GetShape()[i], second.GetShape()[i]); |
| 192 | } |
| 193 | TensorShape broadcastShape = TensorShape(boost::numeric_cast<unsigned int>(outputDims.size()), outputDims.data()); |
| 194 | if (broadcastShape != output.GetShape()) |
| 195 | { |
| 196 | throw InvalidArgumentException(descName + ": The tensor shape resulting from adding " |
| 197 | + firstName + " & " + secondName |
| 198 | + " does not match the output shape"); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | //--------------------------------------------------------------- |
| 203 | /// Validates that the output tensor's quantization scale is greater than the product |
| 204 | /// of the two input tensors' quantization scales. This is a requirement of the implementation of |
| 205 | /// the quantized multiplication. |
| 206 | void ValidateTensorQuantizationMultiplier(const TensorInfo& inputTensor1, const TensorInfo& inputTensor2, |
| 207 | const TensorInfo& outputTensorInfo, std::string const& descName, |
| 208 | const std::string& inputTensor1Name, const std::string& inputTensor2Name, const std::string& outputTensorName) |
| 209 | { |
| 210 | if (outputTensorInfo.GetDataType() == DataType::QuantisedAsymm8) |
| 211 | { |
| 212 | if (outputTensorInfo.GetQuantizationScale() <= |
| 213 | inputTensor1.GetQuantizationScale() * inputTensor2.GetQuantizationScale()) |
| 214 | { |
| 215 | std::stringstream msg; |
| 216 | msg << descName << ": Quantization scale of " << outputTensorName << " is not greater than " << |
| 217 | "the product of the " << inputTensor1Name << " and " << inputTensor2Name << " tensors"; |
| 218 | throw InvalidArgumentException(msg.str()); |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 223 | //--------------------------------------------------------------- |
| 224 | void ValidateDataTypes(const TensorInfo& info, |
| 225 | const std::vector<armnn::DataType>& supportedTypes, |
| 226 | std::string const& descName) |
| 227 | { |
| 228 | auto iterator = std::find(supportedTypes.begin(), supportedTypes.end(), info.GetDataType()); |
| 229 | if (iterator == supportedTypes.end()) |
| 230 | { |
| 231 | throw InvalidArgumentException(descName + ": " + " Tensor type is not supported."); |
| 232 | } |
| 233 | } |
| 234 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 235 | } //namespace |
| 236 | |
| 237 | void QueueDescriptor::ValidateInputsOutputs(const std::string& descName, |
| 238 | unsigned int numExpectedIn, unsigned int numExpectedOut) const |
| 239 | { |
| 240 | ValidateTensors(m_Inputs, numExpectedIn, descName, "input"); |
| 241 | ValidateTensors(m_Outputs, numExpectedOut, descName, "output"); |
| 242 | } |
| 243 | |
| 244 | //--------------------------------------------------------------- |
| 245 | void MemCopyQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 246 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 247 | ValidateNumInputs(workloadInfo, "MemCopyQueueDescriptor", 1); |
| 248 | ValidateNumOutputs(workloadInfo, "MemCopyQueueDescriptor" , 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 249 | |
| 250 | if (workloadInfo.m_InputTensorInfos.size() != workloadInfo.m_OutputTensorInfos.size()) |
| 251 | { |
| 252 | throw InvalidArgumentException(boost::str( |
| 253 | boost::format("Number of input infos (%1%) does not match the number of output infos (%2%)") |
| 254 | % workloadInfo.m_InputTensorInfos.size() % workloadInfo.m_OutputTensorInfos.size())); |
| 255 | } |
| 256 | |
| 257 | for (std::size_t i = 0; i < workloadInfo.m_InputTensorInfos.size(); ++i) |
| 258 | { |
| 259 | if (workloadInfo.m_InputTensorInfos[i].GetNumElements() != |
| 260 | workloadInfo.m_OutputTensorInfos[i].GetNumElements()) |
| 261 | { |
| 262 | throw InvalidArgumentException(boost::str( |
| 263 | boost::format("Number of elements for tensor input and output %1% does not match") |
| 264 | % i )); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | if (m_Inputs.size() != m_Outputs.size()) |
| 269 | { |
| 270 | throw InvalidArgumentException(boost::str( |
| 271 | boost::format("Number of inputs (%1%) does not match the number of outputs (%2%)") |
| 272 | % m_Inputs.size() % m_Outputs.size())); |
| 273 | } |
| 274 | |
| 275 | for (unsigned int i = 0; i < m_Inputs.size(); ++i) |
| 276 | { |
| 277 | if (!m_Inputs[i]) |
| 278 | { |
| 279 | throw InvalidArgumentException(boost::str(boost::format("Invalid null input %1%") % i)); |
| 280 | } |
| 281 | |
| 282 | if (!m_Outputs[i]) |
| 283 | { |
| 284 | throw InvalidArgumentException(boost::str(boost::format("Invalid null output %1%") % i)); |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | //--------------------------------------------------------------- |
| 290 | void ActivationQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 291 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 292 | ValidateNumInputs(workloadInfo, "ActivationQueueDescriptor", 1); |
| 293 | ValidateNumOutputs(workloadInfo, "ActivationQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 294 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 295 | workloadInfo.m_OutputTensorInfos[0], |
| 296 | "ActivationQueueDescriptor", |
| 297 | "input", |
| 298 | "output"); |
| 299 | } |
| 300 | |
| 301 | //--------------------------------------------------------------- |
| 302 | void SoftmaxQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 303 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 304 | ValidateNumInputs(workloadInfo, "SoftmaxQueueDescriptor", 1); |
| 305 | ValidateNumOutputs(workloadInfo, "SoftmaxQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 306 | |
| 307 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 308 | workloadInfo.m_OutputTensorInfos[0], |
| 309 | "SoftmaxQueueDescriptor", |
| 310 | "input", |
| 311 | "output"); |
| 312 | } |
| 313 | |
| 314 | //--------------------------------------------------------------- |
| 315 | void SplitterQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 316 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 317 | ValidateNumInputs(workloadInfo, "SplitterQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 318 | |
| 319 | if (workloadInfo.m_OutputTensorInfos.size() <= 0) |
| 320 | { |
| 321 | throw InvalidArgumentException("SplitterQueueDescriptor: At least one output needs to be provided."); |
| 322 | } |
| 323 | |
| 324 | if (workloadInfo.m_OutputTensorInfos.size() != m_ViewOrigins.size()) |
| 325 | { |
| 326 | throw InvalidArgumentException( |
| 327 | "SplitterQueueDescriptor: Number of split windows " |
| 328 | "has to match number of workloadInfo.m_OutputTensorInfos. " |
| 329 | "Number of windows: " + |
| 330 | to_string(m_ViewOrigins.size()) + |
| 331 | ". Number of workloadInfo.m_OutputTensorInfos: " + to_string(workloadInfo.m_OutputTensorInfos.size())); |
| 332 | } |
| 333 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 334 | //The dimensionality of all the windows has to match the dimensionality (not shape) of the input. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 335 | std::size_t inputDims = workloadInfo.m_InputTensorInfos[0].GetNumDimensions(); |
| 336 | for(unsigned int w = 0; w < m_ViewOrigins.size(); ++w ) |
| 337 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 338 | //Checks that the dimensionality of input is same as the split windows. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 339 | ViewOrigin const& e = m_ViewOrigins[w]; |
| 340 | if (e.m_Origin.size() != inputDims) |
| 341 | { |
| 342 | throw InvalidArgumentException("SplitterQueueDescriptor: Window origin have to " |
| 343 | "have the same dimensionality as the input tensor. " |
| 344 | "Window origin (index: " + |
| 345 | to_string(w) + ") has " + to_string(e.m_Origin.size()) + |
| 346 | " dimensions, the input " |
| 347 | "tensor has " + |
| 348 | to_string(inputDims) + " dimensions."); |
| 349 | } |
| 350 | for (unsigned int i = 0; i < e.m_Origin.size(); ++i) |
| 351 | { |
| 352 | if (e.m_Origin[i] + workloadInfo.m_OutputTensorInfos[w].GetShape()[i] > |
| 353 | workloadInfo.m_InputTensorInfos[0].GetShape()[i]) |
| 354 | { |
| 355 | throw InvalidArgumentException("SplitterQueueDescriptor: Window extent coordinates have to " |
| 356 | "be smaller or equal than the size of the input in that coord."); |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | //--------------------------------------------------------------- |
| 363 | void MergerQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 364 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 365 | ValidateNumOutputs(workloadInfo, "MergerQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 366 | |
| 367 | if (m_Inputs.size() <= 0) |
| 368 | { |
| 369 | throw InvalidArgumentException("MergerQueueDescriptor: At least one input needs to be provided."); |
| 370 | } |
| 371 | if (m_Outputs.size() <= 0) |
| 372 | { |
| 373 | throw InvalidArgumentException("MergerQueueDescriptor: At least one output needs to be provided."); |
| 374 | } |
| 375 | |
| 376 | if (workloadInfo.m_InputTensorInfos.size() <= 0) |
| 377 | { |
| 378 | throw InvalidArgumentException("MergerQueueDescriptor: At least one TensorInfo input needs to be provided."); |
| 379 | } |
| 380 | if (workloadInfo.m_OutputTensorInfos.size() <= 0) |
| 381 | { |
| 382 | throw InvalidArgumentException("MergerQueueDescriptor: At least one TensorInfo output needs to be provided."); |
| 383 | } |
| 384 | |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 385 | if(m_Parameters.GetConcatAxis() > workloadInfo.m_InputTensorInfos[0].GetShape().GetNumDimensions()) |
| 386 | { |
| 387 | throw InvalidArgumentException("Invalid Concatenation Axis provided"); |
| 388 | } |
| 389 | |
| 390 | if (workloadInfo.m_InputTensorInfos[0].GetShape().GetNumDimensions() - m_Parameters.GetConcatAxis() == 1) |
| 391 | { |
| 392 | return; |
| 393 | } |
| 394 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 395 | if (workloadInfo.m_InputTensorInfos.size() != m_ViewOrigins.size()) |
| 396 | { |
| 397 | throw InvalidArgumentException( |
| 398 | "MergerQueueDescriptor: Number of split windows " |
| 399 | "has to match number of workloadInfo.m_InputTensorInfos. " |
| 400 | "Number of windows: " + |
| 401 | to_string(m_ViewOrigins.size()) + |
| 402 | ". Number of workloadInfo.m_InputTensorInfos: " + to_string(workloadInfo.m_InputTensorInfos.size())); |
| 403 | } |
| 404 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 405 | //The dimensionality of all the windows has to match the dimensionality (not shape) of the output. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 406 | std::size_t outputDims = workloadInfo.m_OutputTensorInfos[0].GetNumDimensions(); |
| 407 | for(unsigned int w = 0; w < m_ViewOrigins.size(); ++w ) |
| 408 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 409 | //Checks that the dimensionality of output is same as the split windows. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 410 | ViewOrigin const& e = m_ViewOrigins[w]; |
| 411 | if (e.m_Origin.size() != outputDims) |
| 412 | { |
| 413 | throw InvalidArgumentException("MergerQueueDescriptor: Window origin have to " |
| 414 | "have the same dimensionality as the output tensor. " |
| 415 | "Window origin (index: " + |
| 416 | to_string(w) + ") has " + to_string(e.m_Origin.size()) + |
| 417 | " dimensions, the output " |
| 418 | "tensor has " + |
| 419 | to_string(outputDims) + " dimensions."); |
| 420 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 421 | //Checks that the merge windows are within the output tensor. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 422 | for (unsigned int i = 0; i < e.m_Origin.size(); ++i) |
| 423 | { |
| 424 | if (e.m_Origin[i] + workloadInfo.m_InputTensorInfos[w].GetShape()[i] |
| 425 | > workloadInfo.m_OutputTensorInfos[0].GetShape()[i]) |
| 426 | { |
| 427 | throw InvalidArgumentException("MergerQueueDescriptor: Window extent coordinates have to " |
| 428 | "be smaller or equal than the size of the output in that coord."); |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | //--------------------------------------------------------------- |
| 435 | void FullyConnectedQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 436 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 437 | ValidateNumInputs(workloadInfo, "FullyConnectedQueueDescriptor", 1); |
| 438 | ValidateNumOutputs(workloadInfo, "FullyConnectedQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 439 | ValidateTensorNumDimensions(workloadInfo.m_OutputTensorInfos[0], "FullyConnectedQueueDescriptor", 2, "output"); |
| 440 | |
| 441 | if (!(workloadInfo.m_InputTensorInfos[0].GetNumDimensions() == 2 || |
| 442 | workloadInfo.m_InputTensorInfos[0].GetNumDimensions() == 4)) |
| 443 | { |
| 444 | throw InvalidArgumentException("FullyConnectedQueueDescriptor: Input tensor must have 2 or 4 dimensions."); |
| 445 | } |
| 446 | |
| 447 | if (m_Weight == nullptr) |
| 448 | { |
| 449 | throw InvalidArgumentException("FullyConnectedQueueDescriptor: Weight tensor descriptor is missing."); |
| 450 | } |
| 451 | |
| 452 | ValidateTensorNumDimensions(m_Weight->GetTensorInfo(), "FullyConnectedQueueDescriptor", 2, "weight"); |
| 453 | |
| 454 | if (m_Parameters.m_BiasEnabled) |
| 455 | { |
| 456 | if (m_Bias == nullptr) |
| 457 | { |
| 458 | throw InvalidArgumentException("FullyConnectedQueueDescriptor: Bias is enabled but " |
| 459 | "bias value tensor descriptor is missing."); |
| 460 | } |
| 461 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 462 | // Validates type and quantization values. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 463 | ValidateBiasTensorQuantization(m_Bias->GetTensorInfo(), |
| 464 | workloadInfo.m_InputTensorInfos[0], m_Weight->GetTensorInfo(), "FullyConnectedQueueDescriptor"); |
| 465 | |
| 466 | ValidateTensorDataType(m_Bias->GetTensorInfo(), |
| 467 | GetBiasDataType(workloadInfo.m_InputTensorInfos[0].GetDataType()), |
| 468 | "FullyConnectedQueueDescriptor", "bias"); |
| 469 | |
| 470 | ValidateTensorNumDimensions(m_Bias->GetTensorInfo(), "FullyConnectedQueueDescriptor", 1, "bias"); |
| 471 | } |
| 472 | |
| 473 | ValidateTensorQuantizationMultiplier(workloadInfo.m_InputTensorInfos[0], m_Weight->GetTensorInfo(), |
| 474 | workloadInfo.m_OutputTensorInfos[0], "FullyConnectedQueueDescriptor", "input", "weights", "output"); |
| 475 | } |
| 476 | |
| 477 | //--------------------------------------------------------------- |
| 478 | void NormalizationQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 479 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 480 | ValidateNumInputs(workloadInfo, "NormalizationQueueDescriptor", 1); |
| 481 | ValidateNumOutputs(workloadInfo, "NormalizationQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 482 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 483 | workloadInfo.m_OutputTensorInfos[0], |
| 484 | "NormalizationQueueDescriptor", |
| 485 | "input", |
| 486 | "output"); |
| 487 | } |
| 488 | |
| 489 | void AdditionQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 490 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 491 | ValidateNumInputs(workloadInfo, "AdditionQueueDescriptor", 2); |
| 492 | ValidateNumOutputs(workloadInfo, "AdditionQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 493 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 494 | std::vector<DataType> supportedTypes = { |
| 495 | DataType::Float32, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame^] | 496 | DataType::QuantisedAsymm8, |
| 497 | DataType::QuantisedSymm16 |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 498 | }; |
| 499 | |
| 500 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], |
| 501 | supportedTypes, |
| 502 | "AdditionQueueDescriptor"); |
| 503 | |
| 504 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[1], |
| 505 | supportedTypes, |
| 506 | "AdditionQueueDescriptor"); |
| 507 | |
| 508 | ValidateDataTypes(workloadInfo.m_OutputTensorInfos[0], |
| 509 | supportedTypes, |
| 510 | "AdditionQueueDescriptor"); |
| 511 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 512 | ValidateBroadcastTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 513 | workloadInfo.m_InputTensorInfos[1], |
| 514 | workloadInfo.m_OutputTensorInfos[0], |
| 515 | "AdditionQueueDescriptor", |
| 516 | "first input", |
| 517 | "second input"); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | //--------------------------------------------------------------- |
| 521 | void MultiplicationQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 522 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 523 | ValidateNumInputs(workloadInfo, "MultiplicationQueueDescriptor", 2); |
| 524 | ValidateNumOutputs(workloadInfo, "MultiplicationQueueDescriptor", 1); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 525 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 526 | std::vector<DataType> supportedTypes = { |
| 527 | DataType::Float32, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame^] | 528 | DataType::QuantisedAsymm8, |
| 529 | DataType::QuantisedSymm16 |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 530 | }; |
| 531 | |
| 532 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], |
| 533 | supportedTypes, |
| 534 | "MultiplicationQueueDescriptor"); |
| 535 | |
| 536 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[1], |
| 537 | supportedTypes, |
| 538 | "MultiplicationQueueDescriptor"); |
| 539 | |
| 540 | ValidateDataTypes(workloadInfo.m_OutputTensorInfos[0], |
| 541 | supportedTypes, |
| 542 | "MultiplicationQueueDescriptor"); |
| 543 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 544 | ValidateBroadcastTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 545 | workloadInfo.m_InputTensorInfos[1], |
| 546 | workloadInfo.m_OutputTensorInfos[0], |
| 547 | "MultiplicationQueueDescriptor", |
| 548 | "first input", |
| 549 | "second input"); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | void BatchNormalizationQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 553 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 554 | ValidateNumInputs(workloadInfo, "BatchNormalizationQueueDescriptor", 1); |
| 555 | ValidateNumOutputs(workloadInfo, "BatchNormalizationQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 556 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 557 | workloadInfo.m_OutputTensorInfos[0], |
| 558 | "BatchNormalizationQueueDescriptor", |
| 559 | "input", |
| 560 | "output"); |
| 561 | ValidatePointer(m_Mean, "BatchNormalizationQueueDescriptor", "mean"); |
| 562 | ValidatePointer(m_Variance, "BatchNormalizationQueueDescriptor", "variance"); |
| 563 | ValidatePointer(m_Beta, "BatchNormalizationQueueDescriptor", "beta"); |
| 564 | ValidatePointer(m_Gamma, "BatchNormalizationQueueDescriptor", "gamma"); |
| 565 | |
| 566 | |
| 567 | ValidateTensorNumDimensions(m_Mean->GetTensorInfo(), "BatchNormalizationQueueDescriptor", 1, "mean"); |
| 568 | ValidateTensorNumDimensions(m_Variance->GetTensorInfo(), "BatchNormalizationQueueDescriptor", 1, "variance"); |
| 569 | ValidateTensorNumDimensions(m_Beta->GetTensorInfo(), "BatchNormalizationQueueDescriptor", 1, "beta"); |
| 570 | ValidateTensorNumDimensions(m_Gamma->GetTensorInfo(), "BatchNormalizationQueueDescriptor", 1, "gamma"); |
| 571 | |
| 572 | ValidateTensorShapesMatch( |
| 573 | m_Mean->GetTensorInfo(), m_Variance->GetTensorInfo(), "BatchNormalizationQueueDescriptor", "mean", "variance"); |
| 574 | ValidateTensorShapesMatch( |
| 575 | m_Mean->GetTensorInfo(), m_Beta->GetTensorInfo(), "BatchNormalizationQueueDescriptor", "mean", "beta"); |
| 576 | ValidateTensorShapesMatch( |
| 577 | m_Mean->GetTensorInfo(), m_Gamma->GetTensorInfo(), "BatchNormalizationQueueDescriptor", "mean", "gamma"); |
| 578 | } |
| 579 | |
| 580 | void Convolution2dQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 581 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 582 | ValidateNumInputs(workloadInfo, "Convolution2dQueueDescriptor", 1); |
| 583 | ValidateNumOutputs(workloadInfo, "Convolution2dQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 584 | |
| 585 | ValidateTensorNumDimensions(workloadInfo.m_InputTensorInfos[0], "Convolution2dQueueDescriptor", 4, "input"); |
| 586 | ValidateTensorNumDimensions(workloadInfo.m_OutputTensorInfos[0], "Convolution2dQueueDescriptor", 4, "output"); |
| 587 | |
| 588 | ValidatePointer(m_Weight, "Convolution2dQueueDescriptor", "weight"); |
| 589 | ValidateTensorNumDimensions(m_Weight->GetTensorInfo(), "Convolution2dQueueDescriptor", 4, "weight"); |
| 590 | ValidateTensorDataType(m_Weight->GetTensorInfo(), workloadInfo.m_InputTensorInfos[0].GetDataType(), |
| 591 | "Convolution2dQueueDescriptor", "weight"); |
| 592 | if (m_Parameters.m_BiasEnabled) |
| 593 | { |
| 594 | ValidateTensorNumDimensions(m_Bias->GetTensorInfo(), "Convolution2dQueueDescriptor", 1, "bias"); |
| 595 | ValidateTensorDataType(m_Bias->GetTensorInfo(), |
| 596 | GetBiasDataType(workloadInfo.m_InputTensorInfos[0].GetDataType()), |
| 597 | "Convolution2dQueueDescriptor", "bias"); |
| 598 | ValidateBiasTensorQuantization(m_Bias->GetTensorInfo(), |
| 599 | workloadInfo.m_InputTensorInfos[0], m_Weight->GetTensorInfo(), "Convolution2dQueueDescriptor"); |
| 600 | } |
| 601 | |
| 602 | ValidateTensorQuantizationMultiplier(workloadInfo.m_InputTensorInfos[0], m_Weight->GetTensorInfo(), |
| 603 | workloadInfo.m_OutputTensorInfos[0], "Convolution2dQueueDescriptor", "input", "weights", "output"); |
| 604 | } |
| 605 | |
| 606 | void DepthwiseConvolution2dQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 607 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 608 | ValidateNumInputs(workloadInfo, "DepthwiseConvolution2dQueueDescriptor", 1); |
| 609 | ValidateNumOutputs(workloadInfo, "DepthwiseConvolution2dQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 610 | |
| 611 | ValidateTensorNumDimensions( |
| 612 | workloadInfo.m_InputTensorInfos[0], "DepthwiseConvolution2dQueueDescriptor", 4, "input"); |
| 613 | ValidateTensorNumDimensions( |
| 614 | workloadInfo.m_OutputTensorInfos[0], "DepthwiseConvolution2dQueueDescriptor", 4, "output"); |
| 615 | |
| 616 | ValidatePointer(m_Weight, "DepthwiseConvolution2dQueueDescriptor", "weight"); |
| 617 | ValidateTensorNumDimensions(m_Weight->GetTensorInfo(), "DepthwiseConvolution2dQueueDescriptor", 4, "weight"); |
| 618 | |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 619 | const unsigned int channelIndex = (m_Parameters.m_DataLayout == DataLayout::NCHW) ? 1 : 3; |
| 620 | |
Matteo Martincigh | 747ef82 | 2018-12-18 09:26:39 +0000 | [diff] [blame] | 621 | // Expected weight shape: [ M, I, H, W ] - This shape does NOT depend on the data layout |
| 622 | // inputChannels * channelMultiplier should be equal to outputChannels. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 623 | const unsigned int numWeightChannelMultiplier = m_Weight->GetTensorInfo().GetShape()[0]; |
Matteo Martincigh | 747ef82 | 2018-12-18 09:26:39 +0000 | [diff] [blame] | 624 | const unsigned int numWeightInputChannels = m_Weight->GetTensorInfo().GetShape()[1]; |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 625 | const unsigned int numWeightOutputChannels = workloadInfo.m_OutputTensorInfos[0].GetShape()[channelIndex]; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 626 | if (numWeightChannelMultiplier * numWeightInputChannels != numWeightOutputChannels) |
| 627 | { |
| 628 | throw InvalidArgumentException( |
| 629 | boost::str(boost::format("DepthwiseConvolution2dQueueDescriptor: output_channels (provided %1%) should be " |
| 630 | "equal to input_channels (provided %2%) multiplied by channel_multiplier " |
| 631 | "(provided %3%).") |
| 632 | % numWeightOutputChannels % numWeightInputChannels % numWeightChannelMultiplier)); |
| 633 | } |
| 634 | |
| 635 | if (m_Parameters.m_BiasEnabled) |
| 636 | { |
| 637 | ValidatePointer(m_Bias, "DepthwiseConvolution2dQueueDescriptor", "bias"); |
| 638 | ValidateTensorNumDimensions(m_Bias->GetTensorInfo(), "DepthwiseConvolution2dQueueDescriptor", 1, "bias"); |
| 639 | ValidateBiasTensorQuantization(m_Bias->GetTensorInfo(), |
| 640 | workloadInfo.m_InputTensorInfos[0], m_Weight->GetTensorInfo(), "DepthwiseConvolution2dQueueDescriptor"); |
| 641 | |
| 642 | ValidateTensorDataType(m_Bias->GetTensorInfo(), |
| 643 | GetBiasDataType(workloadInfo.m_InputTensorInfos[0].GetDataType()), |
| 644 | "DepthwiseConvolution2dQueueDescriptor", "bias"); |
| 645 | } |
| 646 | |
| 647 | ValidateTensorQuantizationMultiplier(workloadInfo.m_InputTensorInfos[0], m_Weight->GetTensorInfo(), |
| 648 | workloadInfo.m_OutputTensorInfos[0], "DepthwiseConvolution2dQueueDescriptor", "input", "weights", "output"); |
| 649 | } |
| 650 | |
| 651 | void PermuteQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 652 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 653 | ValidateNumInputs(workloadInfo, "PermuteQueueDescriptor", 1); |
| 654 | ValidateNumOutputs(workloadInfo, "PermuteQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 655 | |
| 656 | const PermutationVector& mapping = m_Parameters.m_DimMappings; |
| 657 | |
| 658 | const TensorInfo& input = workloadInfo.m_InputTensorInfos[0]; |
| 659 | const TensorInfo& output = workloadInfo.m_OutputTensorInfos[0]; |
| 660 | |
| 661 | ValidateTensorNumDimensions(input, "PermuteQueueDescriptor", mapping.GetSize(), "input"); |
| 662 | ValidateTensorNumDimensions(output, "PermuteQueueDescriptor", mapping.GetSize(), "output"); |
| 663 | |
| 664 | for (unsigned int i = 0; i < mapping.GetSize(); ++i) |
| 665 | { |
| 666 | if (input.GetShape()[i] != output.GetShape()[mapping[i]]) |
| 667 | { |
| 668 | throw InvalidArgumentException("PermuteQueueDescriptor: src dimension " + to_string(i) + |
| 669 | " (=" + to_string(input.GetShape()[i]) + ") " + |
| 670 | "must match dst dimension " + to_string(mapping[i]) + |
| 671 | " (=" + to_string(output.GetShape()[mapping[i]]) + ")"); |
| 672 | } |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | void Pooling2dQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 677 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 678 | ValidateNumInputs(workloadInfo, "Pooling2dQueueDescriptor", 1); |
| 679 | ValidateNumOutputs(workloadInfo, "Pooling2dQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 680 | |
| 681 | ValidateTensorNumDimensions(workloadInfo.m_InputTensorInfos[0], "Pooling2dQueueDescriptor", 4, "input"); |
| 682 | ValidateTensorNumDimensions(workloadInfo.m_OutputTensorInfos[0], "Pooling2dQueueDescriptor", 4, "output"); |
| 683 | } |
| 684 | |
| 685 | void ResizeBilinearQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 686 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 687 | ValidateNumInputs(workloadInfo, "ResizeBilinearQueueDescriptor", 1); |
| 688 | ValidateNumOutputs(workloadInfo, "ResizeBilinearQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 689 | |
| 690 | ValidateTensorNumDimensions(workloadInfo.m_InputTensorInfos[0], "ResizeBilinearQueueDescriptor", 4, "input"); |
| 691 | ValidateTensorNumDimensions(workloadInfo.m_OutputTensorInfos[0], "ResizeBilinearQueueDescriptor", 4, "output"); |
| 692 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 693 | // Resizes bilinear only changes width and height: batch and channel count must match. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 694 | { |
| 695 | const unsigned int inputBatchSize = workloadInfo.m_InputTensorInfos[0].GetShape()[0]; |
| 696 | const unsigned int outputBatchSize = workloadInfo.m_OutputTensorInfos[0].GetShape()[0]; |
| 697 | if (inputBatchSize != outputBatchSize) |
| 698 | { |
| 699 | throw InvalidArgumentException( |
| 700 | boost::str(boost::format("ResizeBilinearQueueDescriptor: Input batch size (%1%) " |
| 701 | "does not match output batch size (%2%)") % inputBatchSize % outputBatchSize)); |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | { |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 706 | DataLayoutIndexed dimensionIndices(m_Parameters.m_DataLayout); |
James Conroy | 5954082 | 2018-10-11 12:39:05 +0100 | [diff] [blame] | 707 | const unsigned int inputChannelCount = |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 708 | workloadInfo.m_InputTensorInfos[0].GetShape()[dimensionIndices.GetChannelsIndex()]; |
James Conroy | 5954082 | 2018-10-11 12:39:05 +0100 | [diff] [blame] | 709 | const unsigned int outputChannelCount = |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 710 | workloadInfo.m_OutputTensorInfos[0].GetShape()[dimensionIndices.GetChannelsIndex()]; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 711 | if (inputChannelCount != outputChannelCount) |
| 712 | { |
| 713 | throw InvalidArgumentException( |
| 714 | boost::str(boost::format("ResizeBilinearQueueDescriptor: Input channel count (%1%) " |
| 715 | "does not match output channel count (%2%)") % inputChannelCount % outputChannelCount)); |
| 716 | } |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | void FakeQuantizationQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 721 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 722 | ValidateNumInputs(workloadInfo, "FakeQuantizationQueueDescriptor", 1); |
| 723 | ValidateNumOutputs(workloadInfo, "FakeQuantizationQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 724 | |
| 725 | ValidateTensorNumDimensions(workloadInfo.m_InputTensorInfos[0], "FakeQuantizationQueueDescriptor", 2, "input"); |
| 726 | ValidateTensorNumDimensions(workloadInfo.m_OutputTensorInfos[0], "FakeQuantizationQueueDescriptor", 2, "output"); |
| 727 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 728 | workloadInfo.m_OutputTensorInfos[0], |
| 729 | "FakeQuantizationQueueDescriptor", |
| 730 | "input", |
| 731 | "output"); |
| 732 | if (m_Parameters.m_Min > m_Parameters.m_Max) |
| 733 | { |
| 734 | throw InvalidArgumentException("FakeQuantizationQueueDescriptor: min cannot be greater than max"); |
| 735 | } |
| 736 | |
| 737 | } |
| 738 | |
| 739 | void L2NormalizationQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 740 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 741 | ValidateNumInputs(workloadInfo, "L2NormalizationQueueDescriptor", 1); |
| 742 | ValidateNumOutputs(workloadInfo, "L2NormalizationQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 743 | |
| 744 | ValidateTensorNumDimensions(workloadInfo.m_InputTensorInfos[0], "L2NormalizationQueueDescriptor", 4, "input"); |
| 745 | ValidateTensorNumDimensions(workloadInfo.m_OutputTensorInfos[0], "L2NormalizationQueueDescriptor", 4, "output"); |
| 746 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 747 | workloadInfo.m_OutputTensorInfos[0], |
| 748 | "L2NormalizationQueueDescriptor", |
| 749 | "input", |
| 750 | "output"); |
| 751 | } |
| 752 | |
| 753 | void ConstantQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 754 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 755 | ValidateNumInputs(workloadInfo, "ConstantQueueDescriptor", 0); |
| 756 | ValidateNumOutputs(workloadInfo, "ConstantQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 757 | |
| 758 | if (!m_LayerOutput) |
| 759 | { |
| 760 | throw InvalidArgumentException("ConstantQueueDescriptor: No const input specified"); |
| 761 | } |
| 762 | |
| 763 | ValidateTensorShapesMatch(m_LayerOutput->GetTensorInfo(), |
| 764 | workloadInfo.m_OutputTensorInfos[0], |
| 765 | "ConstantQueueDescriptor", |
| 766 | "constant", |
| 767 | "output"); |
| 768 | } |
| 769 | |
| 770 | void ReshapeQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 771 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 772 | ValidateNumInputs(workloadInfo, "ReshapeQueueDescriptor", 1); |
| 773 | ValidateNumOutputs(workloadInfo, "ReshapeQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 774 | |
| 775 | if (workloadInfo.m_InputTensorInfos[0].GetNumElements() != workloadInfo.m_OutputTensorInfos[0].GetNumElements()) |
| 776 | { |
| 777 | throw InvalidArgumentException("ReshapeQueueDescriptor: Input tensor has " + |
| 778 | to_string(workloadInfo.m_InputTensorInfos[0].GetNumElements()) + " but output tensor has " + |
| 779 | to_string(workloadInfo.m_OutputTensorInfos[0].GetNumElements()) + " elements."); |
| 780 | } |
| 781 | } |
| 782 | |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 783 | void SpaceToBatchNdQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 784 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 785 | ValidateNumInputs(workloadInfo, "SpaceToBatchNdQueueDescriptor", 1); |
| 786 | ValidateNumOutputs(workloadInfo, "SpaceToBatchNdQueueDescriptor", 1); |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 787 | |
| 788 | ValidateTensorNumDimensions(workloadInfo.m_InputTensorInfos[0], "SpaceToBatchNdQueueDescriptor", 4, "input"); |
| 789 | ValidateTensorNumDimensions(workloadInfo.m_OutputTensorInfos[0], "SpaceToBatchNdQueueDescriptor", 4, "output"); |
| 790 | |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 791 | if (m_Parameters.m_BlockShape.size() != 2) |
| 792 | { |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 793 | throw InvalidArgumentException("Block Shape must contain 2 spatial dimensions"); |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | if (m_Parameters.m_BlockShape.size() != m_Parameters.m_PadList.size()) |
| 797 | { |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 798 | throw InvalidArgumentException("Pad List must contain the same number of dimensions as Block Shape."); |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | const TensorShape inputShape = workloadInfo.m_InputTensorInfos[0].GetShape(); |
| 802 | |
| 803 | std::pair<unsigned int, unsigned int> heightPad = m_Parameters.m_PadList[0]; |
| 804 | std::pair<unsigned int, unsigned int> widthPad = m_Parameters.m_PadList[1]; |
| 805 | |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 806 | DataLayoutIndexed dimensionIndices(m_Parameters.m_DataLayout); |
| 807 | unsigned int inputHeight = inputShape[dimensionIndices.GetHeightIndex()] |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 808 | + heightPad.first + heightPad.second; |
| 809 | |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 810 | unsigned int inputWidth = inputShape[dimensionIndices.GetWidthIndex()] |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 811 | + widthPad.first + widthPad.second; |
| 812 | |
| 813 | unsigned int numInputElements = inputShape[0] * inputHeight * inputWidth |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 814 | * inputShape[dimensionIndices.GetChannelsIndex()]; |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 815 | |
| 816 | if (workloadInfo.m_OutputTensorInfos[0].GetNumElements() != numInputElements) |
| 817 | { |
| 818 | throw InvalidArgumentException("SpaceToBatchNdQueueDescriptor: Input tensor has " + |
| 819 | to_string(numInputElements) + " after padding but output tensor has " + |
| 820 | to_string(workloadInfo.m_OutputTensorInfos[0].GetNumElements()) + " elements."); |
| 821 | } |
| 822 | |
| 823 | if (inputHeight % m_Parameters.m_BlockShape[0] != 0 || inputWidth % m_Parameters.m_BlockShape[1] != 0) |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 824 | { |
| 825 | throw InvalidArgumentException( |
| 826 | "Input shape after padding must be divisible by Block Shape in all spatial dimensions"); |
| 827 | } |
| 828 | } |
| 829 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 830 | void FloorQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 831 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 832 | ValidateNumInputs(workloadInfo, "FloorQueueDescriptor", 1); |
| 833 | ValidateNumOutputs(workloadInfo, "FlootQueueDescriptor", 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 834 | |
| 835 | if (workloadInfo.m_InputTensorInfos[0] != workloadInfo.m_OutputTensorInfos[0]) |
| 836 | { |
| 837 | throw InvalidArgumentException("FloorQueueDescriptor: Input and output tensor infos do not match."); |
| 838 | } |
| 839 | } |
| 840 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 841 | void LstmQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 842 | { |
| 843 | ValidateTensorNumDimensions(workloadInfo.m_InputTensorInfos[0], "LstmQueueDescriptor", 2, "input"); |
| 844 | ValidateTensorNumDimensions(workloadInfo.m_OutputTensorInfos[0], "LstmQueueDescriptor", 2, "output"); |
| 845 | } |
| 846 | |
| 847 | void ConvertFp32ToFp16QueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 848 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 849 | ValidateNumInputs(workloadInfo, "ConvertFp32ToFp16QueueDescriptor", 1); |
| 850 | ValidateNumOutputs(workloadInfo, "ConvertFp32ToFp16QueueDescriptor", 1); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 851 | |
| 852 | if (workloadInfo.m_InputTensorInfos[0].GetDataType() != DataType::Float32) |
| 853 | { |
| 854 | throw InvalidArgumentException("ConvertFp32ToFp16QueueDescriptor: Input tensor type must be Float32."); |
| 855 | } |
| 856 | |
| 857 | if (workloadInfo.m_OutputTensorInfos[0].GetDataType() != DataType::Float16) |
| 858 | { |
| 859 | throw InvalidArgumentException("ConvertFp32ToFp16QueueDescriptor: Output tensor type must be Float16."); |
| 860 | } |
| 861 | |
| 862 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 863 | workloadInfo.m_OutputTensorInfos[0], |
| 864 | "ConvertFp32ToFp16QueueDescriptor", |
| 865 | "input", |
| 866 | "output"); |
| 867 | } |
| 868 | |
| 869 | void ConvertFp16ToFp32QueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 870 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 871 | ValidateNumInputs(workloadInfo, "ConvertFp16ToFp32QueueDescriptor", 1); |
| 872 | ValidateNumOutputs(workloadInfo, "ConvertFp16ToFp32QueueDescriptor", 1); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 873 | |
| 874 | if (workloadInfo.m_InputTensorInfos[0].GetDataType() != DataType::Float16) |
| 875 | { |
| 876 | throw InvalidArgumentException("ConvertFp16ToFp32QueueDescriptor: Input tensor type must be Float16."); |
| 877 | } |
| 878 | if (workloadInfo.m_OutputTensorInfos[0].GetDataType() != DataType::Float32) |
| 879 | { |
| 880 | throw InvalidArgumentException("ConvertFp16ToFp32QueueDescriptor: Output tensor type must be Float32."); |
| 881 | } |
| 882 | |
| 883 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 884 | workloadInfo.m_OutputTensorInfos[0], |
| 885 | "ConvertFp16ToFp32QueueDescriptor", |
| 886 | "input", |
| 887 | "output"); |
| 888 | } |
| 889 | |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 890 | void DivisionQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 891 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 892 | ValidateNumInputs(workloadInfo, "DivisionQueueDescriptor", 2); |
| 893 | ValidateNumOutputs(workloadInfo, "DivisionQueueDescriptor", 1); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 894 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 895 | std::vector<DataType> supportedTypes = { |
| 896 | DataType::Float32, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame^] | 897 | DataType::QuantisedAsymm8, |
| 898 | DataType::QuantisedSymm16 |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 899 | }; |
| 900 | |
| 901 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], |
| 902 | supportedTypes, |
| 903 | "DivisionQueueDescriptor"); |
| 904 | |
| 905 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[1], |
| 906 | supportedTypes, |
| 907 | "DivisionQueueDescriptor"); |
| 908 | |
| 909 | ValidateDataTypes(workloadInfo.m_OutputTensorInfos[0], |
| 910 | supportedTypes, |
| 911 | "DivisionQueueDescriptor"); |
| 912 | |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 913 | ValidateBroadcastTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 914 | workloadInfo.m_InputTensorInfos[1], |
| 915 | workloadInfo.m_OutputTensorInfos[0], |
| 916 | "DivisionQueueDescriptor", |
| 917 | "first input", |
| 918 | "second input"); |
| 919 | } |
| 920 | |
David Beck | c2044fe | 2018-09-05 15:00:38 +0100 | [diff] [blame] | 921 | void SubtractionQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 922 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 923 | ValidateNumInputs(workloadInfo, "SubtractionQueueDescriptor", 2); |
| 924 | ValidateNumOutputs(workloadInfo, "SubtractionQueueDescriptor", 1); |
David Beck | c2044fe | 2018-09-05 15:00:38 +0100 | [diff] [blame] | 925 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 926 | std::vector<DataType> supportedTypes = { |
| 927 | DataType::Float32, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame^] | 928 | DataType::QuantisedAsymm8, |
| 929 | DataType::QuantisedSymm16 |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 930 | }; |
| 931 | |
| 932 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], |
| 933 | supportedTypes, |
| 934 | "SubtractionQueueDescriptor"); |
| 935 | |
| 936 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[1], |
| 937 | supportedTypes, |
| 938 | "SubtractionQueueDescriptor"); |
| 939 | |
| 940 | ValidateDataTypes(workloadInfo.m_OutputTensorInfos[0], |
| 941 | supportedTypes, |
| 942 | "SubtractionQueueDescriptor"); |
| 943 | |
David Beck | c2044fe | 2018-09-05 15:00:38 +0100 | [diff] [blame] | 944 | ValidateBroadcastTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 945 | workloadInfo.m_InputTensorInfos[1], |
| 946 | workloadInfo.m_OutputTensorInfos[0], |
| 947 | "SubtractionQueueDescriptor", |
| 948 | "first input", |
| 949 | "second input"); |
| 950 | } |
| 951 | |
Nattapat Chaimanowong | 5a4304a | 2018-11-28 10:44:37 +0000 | [diff] [blame] | 952 | void MaximumQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 953 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 954 | ValidateNumInputs(workloadInfo, "MaximumQueueDescriptor", 2); |
| 955 | ValidateNumOutputs(workloadInfo, "MaximumQueueDescriptor", 1); |
Nattapat Chaimanowong | 5a4304a | 2018-11-28 10:44:37 +0000 | [diff] [blame] | 956 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 957 | std::vector<DataType> supportedTypes = { |
| 958 | DataType::Float32, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame^] | 959 | DataType::QuantisedAsymm8, |
| 960 | DataType::QuantisedSymm16 |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 961 | }; |
| 962 | |
| 963 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], |
| 964 | supportedTypes, |
| 965 | "MaximumQueueDescriptor"); |
| 966 | |
| 967 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[1], |
| 968 | supportedTypes, |
| 969 | "MaximumQueueDescriptor"); |
| 970 | |
| 971 | ValidateDataTypes(workloadInfo.m_OutputTensorInfos[0], |
| 972 | supportedTypes, |
| 973 | "MaximumQueueDescriptor"); |
| 974 | |
Nattapat Chaimanowong | 5a4304a | 2018-11-28 10:44:37 +0000 | [diff] [blame] | 975 | ValidateBroadcastTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 976 | workloadInfo.m_InputTensorInfos[1], |
| 977 | workloadInfo.m_OutputTensorInfos[0], |
| 978 | "MaximumQueueDescriptor", |
| 979 | "first input", |
| 980 | "second input"); |
| 981 | } |
| 982 | |
narpra01 | a6bf912 | 2018-09-10 09:50:09 +0100 | [diff] [blame] | 983 | void MeanQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 984 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 985 | ValidateNumInputs(workloadInfo, "MeanQueueDescriptor", 1); |
| 986 | ValidateNumOutputs(workloadInfo, "MeanQueueDescriptor", 1); |
narpra01 | eb06191 | 2018-09-10 17:35:27 +0100 | [diff] [blame] | 987 | |
| 988 | const TensorInfo& input = workloadInfo.m_InputTensorInfos[0]; |
| 989 | const TensorInfo& output = workloadInfo.m_OutputTensorInfos[0]; |
| 990 | |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 991 | if (m_Parameters.m_KeepDims) |
narpra01 | eb06191 | 2018-09-10 17:35:27 +0100 | [diff] [blame] | 992 | { |
| 993 | ValidateTensorNumDimensions(output, "MeanQueueDescriptor", input.GetNumDimensions(), "output"); |
| 994 | } |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 995 | else if (m_Parameters.m_Axis.empty()) |
narpra01 | eb06191 | 2018-09-10 17:35:27 +0100 | [diff] [blame] | 996 | { |
| 997 | ValidateTensorNumDimensions(output, "MeanQueueDescriptor", 1, "output"); |
| 998 | } |
| 999 | else |
| 1000 | { |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1001 | auto outputDim = input.GetNumDimensions() - boost::numeric_cast<unsigned int>(m_Parameters.m_Axis.size()); |
narpra01 | eb06191 | 2018-09-10 17:35:27 +0100 | [diff] [blame] | 1002 | ValidateTensorNumDimensions(output, |
| 1003 | "MeanQueueDescriptor", |
| 1004 | outputDim > 0 ? outputDim : 1, |
| 1005 | "output"); |
| 1006 | } |
narpra01 | a6bf912 | 2018-09-10 09:50:09 +0100 | [diff] [blame] | 1007 | } |
| 1008 | |
jimfly01 | 2c9322a | 2018-09-19 10:59:49 +0100 | [diff] [blame] | 1009 | void PadQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1010 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1011 | ValidateNumInputs(workloadInfo, "PadQueueDescriptor", 1); |
| 1012 | ValidateNumOutputs(workloadInfo, "PadQueueDescriptor", 1); |
jimfly01 | 2c9322a | 2018-09-19 10:59:49 +0100 | [diff] [blame] | 1013 | |
| 1014 | const TensorInfo& input = workloadInfo.m_InputTensorInfos[0]; |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1015 | const TensorInfo& output = workloadInfo.m_OutputTensorInfos[0]; |
| 1016 | |
jimfly01 | 2c9322a | 2018-09-19 10:59:49 +0100 | [diff] [blame] | 1017 | // input and output should have the same number of dimensions |
| 1018 | ValidateTensorNumDimensions(output, "PadQueueDescriptor", input.GetNumDimensions(), "output"); |
| 1019 | // there should be entry in the pad list for each dimension in the input tensor |
| 1020 | if (m_Parameters.m_PadList.size() != input.GetNumDimensions()) { |
| 1021 | throw InvalidArgumentException("Pad List should contain the same number of entries as there" |
| 1022 | " are dimensions in the input tensor that is " + |
| 1023 | to_string(input.GetNumDimensions()) + " entries " + |
| 1024 | " not " + to_string(m_Parameters.m_PadList.size()) + " entries."); |
| 1025 | } |
| 1026 | } |
| 1027 | |
Derek Lamberti | a9cca6a | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1028 | void QuantizeQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1029 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1030 | ValidateNumInputs(workloadInfo, "QuantizeQueueDescriptor", 1); |
| 1031 | ValidateNumOutputs(workloadInfo, "QuantizeQueueDescriptor", 1); |
Derek Lamberti | a9cca6a | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1032 | |
| 1033 | |
| 1034 | if (workloadInfo.m_InputTensorInfos[0].GetDataType() != DataType::Float32) |
| 1035 | { |
| 1036 | throw InvalidArgumentException("Quantize only accepts Float32 inputs."); |
| 1037 | } |
| 1038 | |
| 1039 | if (workloadInfo.m_OutputTensorInfos[0].GetDataType() != DataType::QuantisedAsymm8 && |
| 1040 | workloadInfo.m_OutputTensorInfos[0].GetDataType() != DataType::QuantisedSymm16) |
| 1041 | { |
| 1042 | throw InvalidArgumentException("Output of quantized layer must be quantized type."); |
| 1043 | } |
| 1044 | } |
| 1045 | |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 1046 | void BatchToSpaceNdQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1047 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1048 | ValidateNumInputs(workloadInfo, "BatchToSpaceNdQueueDescriptor", 1); |
| 1049 | ValidateNumOutputs(workloadInfo, "BatchToSpaceNdQueueDescriptor", 1); |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 1050 | } |
| 1051 | |
Conor Kennedy | 430b5d8 | 2018-11-14 15:28:28 +0000 | [diff] [blame] | 1052 | void StridedSliceQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1053 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1054 | ValidateNumInputs(workloadInfo, "StridedSliceQueueDescriptor", 1); |
| 1055 | ValidateNumOutputs(workloadInfo, "StridedSliceQueueDescriptor", 1); |
Conor Kennedy | 430b5d8 | 2018-11-14 15:28:28 +0000 | [diff] [blame] | 1056 | |
| 1057 | const TensorInfo& input = workloadInfo.m_InputTensorInfos[0]; |
| 1058 | const uint32_t rank = input.GetNumDimensions(); |
| 1059 | |
Nattapat Chaimanowong | a0d2844 | 2018-11-21 16:48:17 +0000 | [diff] [blame] | 1060 | if (rank > 4) |
| 1061 | { |
| 1062 | throw InvalidArgumentException( |
| 1063 | "StridedSliceLayer: Input tensors with rank greater than 4 are not supported"); |
| 1064 | } |
| 1065 | |
Conor Kennedy | 430b5d8 | 2018-11-14 15:28:28 +0000 | [diff] [blame] | 1066 | // Begin, End & Stride length must be of rank(input0) |
| 1067 | if (m_Parameters.m_Begin.size() != rank) |
| 1068 | { |
| 1069 | throw InvalidArgumentException("StridedSliceLayer: Begin length must be of rank input0(" |
| 1070 | + to_string(rank) + ")"); |
| 1071 | } |
| 1072 | |
| 1073 | if (m_Parameters.m_End.size() != rank) |
| 1074 | { |
| 1075 | throw InvalidArgumentException("StridedSliceLayer: End length must be of rank input0(" |
| 1076 | + to_string(rank) + ")"); |
| 1077 | } |
| 1078 | |
| 1079 | if (m_Parameters.m_Stride.size() != rank) |
| 1080 | { |
| 1081 | throw InvalidArgumentException("StridedSliceLayer: Stride length must be of rank input0(" |
| 1082 | + to_string(rank) + ")"); |
| 1083 | } |
| 1084 | |
| 1085 | // Stride entries must be non-zero |
| 1086 | for (auto& stride : m_Parameters.m_Stride) |
| 1087 | { |
| 1088 | if (stride == 0) |
| 1089 | { |
| 1090 | throw InvalidArgumentException("StridedSliceLayer: Stride entries must be non-zero"); |
| 1091 | } |
| 1092 | } |
| 1093 | } |
| 1094 | |
kevmay01 | 9053969 | 2018-11-29 08:40:19 +0000 | [diff] [blame] | 1095 | void MinimumQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1096 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1097 | ValidateNumInputs(workloadInfo, "MinimumQueueDescriptor", 2); |
| 1098 | ValidateNumOutputs(workloadInfo, "MinimumQueueDescriptor", 1); |
kevmay01 | 9053969 | 2018-11-29 08:40:19 +0000 | [diff] [blame] | 1099 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 1100 | std::vector<DataType> supportedTypes = { |
| 1101 | DataType::Float32, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame^] | 1102 | DataType::QuantisedAsymm8, |
| 1103 | DataType::QuantisedSymm16 |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 1104 | }; |
| 1105 | |
| 1106 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], |
| 1107 | supportedTypes, |
| 1108 | "MinimumQueueDescriptor"); |
| 1109 | |
| 1110 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[1], |
| 1111 | supportedTypes, |
| 1112 | "MinimumQueueDescriptor"); |
| 1113 | |
| 1114 | ValidateDataTypes(workloadInfo.m_OutputTensorInfos[0], |
| 1115 | supportedTypes, |
| 1116 | "MinimumQueueDescriptor"); |
| 1117 | |
kevmay01 | 9053969 | 2018-11-29 08:40:19 +0000 | [diff] [blame] | 1118 | ValidateBroadcastTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 1119 | workloadInfo.m_InputTensorInfos[1], |
| 1120 | workloadInfo.m_OutputTensorInfos[0], |
| 1121 | "MinimumQueueDescriptor", |
| 1122 | "first input", |
| 1123 | "second input"); |
| 1124 | } |
| 1125 | |
Nattapat Chaimanowong | a9a1cf1 | 2018-12-03 16:06:49 +0000 | [diff] [blame] | 1126 | void DebugQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1127 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1128 | ValidateNumInputs(workloadInfo, "DebugQueueDescriptor", 1); |
| 1129 | ValidateNumOutputs(workloadInfo, "DebugQueueDescriptor", 1); |
Nattapat Chaimanowong | a9a1cf1 | 2018-12-03 16:06:49 +0000 | [diff] [blame] | 1130 | } |
| 1131 | |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 1132 | void EqualQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1133 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1134 | ValidateNumInputs(workloadInfo, "EqualQueueDescriptor", 2); |
| 1135 | ValidateNumOutputs(workloadInfo, "EqualQueueDescriptor", 1); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 1136 | |
| 1137 | ValidateBroadcastTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 1138 | workloadInfo.m_InputTensorInfos[1], |
| 1139 | workloadInfo.m_OutputTensorInfos[0], |
| 1140 | "EqualQueueDescriptor", |
| 1141 | "first input", |
| 1142 | "second input"); |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 1143 | |
| 1144 | if (workloadInfo.m_OutputTensorInfos[0].GetDataType() != DataType::Boolean) |
| 1145 | { |
| 1146 | throw InvalidArgumentException("EqualQueueDescriptor: Output tensor type must be Boolean."); |
| 1147 | } |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 1148 | } |
| 1149 | |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 1150 | void GreaterQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1151 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1152 | ValidateNumInputs(workloadInfo, "GreaterQueueDescriptor", 2); |
| 1153 | ValidateNumOutputs(workloadInfo, "GreaterQueueDescriptor", 1); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 1154 | |
| 1155 | ValidateBroadcastTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 1156 | workloadInfo.m_InputTensorInfos[1], |
| 1157 | workloadInfo.m_OutputTensorInfos[0], |
| 1158 | "GreaterQueueDescriptor", |
| 1159 | "first input", |
| 1160 | "second input"); |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 1161 | |
| 1162 | if (workloadInfo.m_OutputTensorInfos[0].GetDataType() != DataType::Boolean) |
| 1163 | { |
| 1164 | throw InvalidArgumentException("GreaterQueueDescriptor: Output tensor type must be Boolean."); |
| 1165 | } |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 1166 | } |
| 1167 | |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 1168 | void RsqrtQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1169 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1170 | ValidateNumInputs(workloadInfo, "RsqrtQueueDescriptor", 1); |
| 1171 | ValidateNumOutputs(workloadInfo, "RsqrtQueueDescriptor", 1); |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 1172 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 1173 | workloadInfo.m_OutputTensorInfos[0], |
| 1174 | "RsqrtQueueDescriptor", |
| 1175 | "input", |
| 1176 | "output"); |
| 1177 | } |
| 1178 | |
narpra01 | b89b05f | 2019-01-16 09:53:09 +0000 | [diff] [blame] | 1179 | void GatherQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1180 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1181 | ValidateNumInputs(workloadInfo, "GatherQueueDescriptor", 2); |
| 1182 | ValidateNumOutputs(workloadInfo, "GatherQueueDescriptor", 1); |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 1183 | |
| 1184 | const TensorInfo& indices = workloadInfo.m_InputTensorInfos[1]; |
| 1185 | |
| 1186 | if (indices.GetDataType() != DataType::Signed32) |
| 1187 | { |
| 1188 | throw InvalidArgumentException("GatherQueueDescriptor: Indices tensor type must be int32."); |
| 1189 | } |
| 1190 | |
| 1191 | const TensorInfo& params = workloadInfo.m_InputTensorInfos[0]; |
| 1192 | const TensorInfo& output = workloadInfo.m_OutputTensorInfos[0]; |
| 1193 | unsigned int paramsDim = params.GetNumDimensions(); |
| 1194 | unsigned int indicesDim = indices.GetNumDimensions(); |
| 1195 | unsigned int outputDim = paramsDim - 1 + indicesDim; |
| 1196 | |
| 1197 | ValidateTensorNumDimensions(output, "GatherQueueDescriptor", outputDim, "output"); |
narpra01 | b89b05f | 2019-01-16 09:53:09 +0000 | [diff] [blame] | 1198 | } |
| 1199 | |
Narumol Prangnawarat | bc67cef | 2019-01-31 15:31:54 +0000 | [diff] [blame] | 1200 | void DetectionPostProcessQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1201 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1202 | ValidateNumInputs(workloadInfo, "DetectionPostProcessQueueDescriptor", 2); |
Narumol Prangnawarat | bc67cef | 2019-01-31 15:31:54 +0000 | [diff] [blame] | 1203 | |
| 1204 | if (workloadInfo.m_OutputTensorInfos.size() != 4) |
| 1205 | { |
| 1206 | throw InvalidArgumentException("DetectionPostProcessQueueDescriptor: Requires exactly four outputs. " + |
| 1207 | to_string(workloadInfo.m_OutputTensorInfos.size()) + " has been provided."); |
| 1208 | } |
| 1209 | |
| 1210 | if (m_Anchors == nullptr) |
| 1211 | { |
| 1212 | throw InvalidArgumentException("DetectionPostProcessQueueDescriptor: Anchors tensor descriptor is missing."); |
| 1213 | } |
| 1214 | |
| 1215 | const TensorInfo& boxEncodingsInfo = workloadInfo.m_InputTensorInfos[0]; |
| 1216 | const TensorInfo& scoresInfo = workloadInfo.m_InputTensorInfos[1]; |
| 1217 | const TensorInfo& anchorsInfo = m_Anchors->GetTensorInfo(); |
| 1218 | const TensorInfo& detectionBoxesInfo = workloadInfo.m_OutputTensorInfos[0]; |
Narumol Prangnawarat | 6d302bf | 2019-02-04 11:46:26 +0000 | [diff] [blame] | 1219 | const TensorInfo& detectionClassesInfo = workloadInfo.m_OutputTensorInfos[1]; |
| 1220 | const TensorInfo& detectionScoresInfo = workloadInfo.m_OutputTensorInfos[2]; |
Narumol Prangnawarat | bc67cef | 2019-01-31 15:31:54 +0000 | [diff] [blame] | 1221 | const TensorInfo& numDetectionsInfo = workloadInfo.m_OutputTensorInfos[3]; |
| 1222 | |
| 1223 | ValidateTensorNumDimensions(boxEncodingsInfo, "DetectionPostProcessQueueDescriptor", 3, "box encodings"); |
| 1224 | ValidateTensorNumDimensions(scoresInfo, "DetectionPostProcessQueueDescriptor", 3, "scores"); |
| 1225 | ValidateTensorNumDimensions(anchorsInfo, "DetectionPostProcessQueueDescriptor", 2, "anchors"); |
| 1226 | |
| 1227 | ValidateTensorNumDimensions(detectionBoxesInfo, "DetectionPostProcessQueueDescriptor", 3, "detection boxes"); |
| 1228 | ValidateTensorNumDimensions(detectionScoresInfo, "DetectionPostProcessQueueDescriptor", 2, "detection scores"); |
| 1229 | ValidateTensorNumDimensions(detectionClassesInfo, "DetectionPostProcessQueueDescriptor", 2, "detection classes"); |
| 1230 | ValidateTensorNumDimensions(numDetectionsInfo, "DetectionPostProcessQueueDescriptor", 1, "num detections"); |
| 1231 | |
| 1232 | ValidateTensorDataType(detectionBoxesInfo, DataType::Float32, |
| 1233 | "DetectionPostProcessQueueDescriptor", "detection boxes"); |
| 1234 | ValidateTensorDataType(detectionScoresInfo, DataType::Float32, |
| 1235 | "DetectionPostProcessQueueDescriptor", "detection scores"); |
| 1236 | ValidateTensorDataType(detectionClassesInfo, DataType::Float32, |
| 1237 | "DetectionPostProcessQueueDescriptor", "detection classes"); |
| 1238 | ValidateTensorDataType(numDetectionsInfo, DataType::Float32, |
| 1239 | "DetectionPostProcessQueueDescriptor", "num detections"); |
| 1240 | |
| 1241 | if (m_Parameters.m_NmsIouThreshold <= 0.0f || m_Parameters.m_NmsIouThreshold > 1.0f) |
| 1242 | { |
| 1243 | throw InvalidArgumentException("DetectionPostProcessQueueDescriptor: Intersection over union threshold " |
| 1244 | "must be positive and less than or equal to 1."); |
| 1245 | } |
| 1246 | if (scoresInfo.GetShape()[2] != m_Parameters.m_NumClasses + 1) |
| 1247 | { |
| 1248 | throw InvalidArgumentException("DetectionPostProcessQueueDescriptor: Number of classes with background " |
| 1249 | "should be equal to number of classes + 1."); |
| 1250 | } |
| 1251 | } |
| 1252 | |
Nattapat Chaimanowong | e4294fd | 2019-03-28 09:56:53 +0000 | [diff] [blame] | 1253 | void DequantizeQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1254 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1255 | ValidateNumInputs(workloadInfo, "DequantizeQueueDescriptor", 1); |
| 1256 | ValidateNumOutputs(workloadInfo, "DequantizeQueueDescriptor", 1); |
Nattapat Chaimanowong | e4294fd | 2019-03-28 09:56:53 +0000 | [diff] [blame] | 1257 | |
| 1258 | if (workloadInfo.m_InputTensorInfos[0].GetDataType() != DataType::QuantisedAsymm8 && |
| 1259 | workloadInfo.m_InputTensorInfos[0].GetDataType() != DataType::QuantisedSymm16) |
| 1260 | { |
| 1261 | throw InvalidArgumentException("Input to dequantize layer must be quantized type."); |
| 1262 | } |
| 1263 | |
| 1264 | if (workloadInfo.m_OutputTensorInfos[0].GetDataType() != DataType::Float32) |
| 1265 | { |
| 1266 | throw InvalidArgumentException("Output of dequantize layer must be Float32 type."); |
| 1267 | } |
| 1268 | } |
| 1269 | |
Nattapat Chaimanowong | 1f88630 | 2019-04-05 13:37:19 +0100 | [diff] [blame] | 1270 | void MergeQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1271 | { |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1272 | ValidateNumInputs(workloadInfo, "MergeQueueDescriptor", 2); |
| 1273 | ValidateNumOutputs(workloadInfo, "MergeQueueDescriptor", 1); |
Nattapat Chaimanowong | 1f88630 | 2019-04-05 13:37:19 +0100 | [diff] [blame] | 1274 | |
| 1275 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 1276 | workloadInfo.m_InputTensorInfos[1], |
| 1277 | "MergeQueueDescriptor", |
| 1278 | "input0", |
| 1279 | "input1"); |
| 1280 | |
| 1281 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 1282 | workloadInfo.m_OutputTensorInfos[0], |
| 1283 | "MergeQueueDescriptor", |
| 1284 | "input0", |
| 1285 | "output"); |
| 1286 | |
| 1287 | const DataType dataType = workloadInfo.m_InputTensorInfos[0].GetDataType(); |
| 1288 | ValidateTensorDataType(workloadInfo.m_InputTensorInfos[1], dataType, "MergeQueueDescriptor", "input1"); |
| 1289 | ValidateTensorDataType(workloadInfo.m_OutputTensorInfos[0], dataType, "MergeQueueDescriptor", "output"); |
| 1290 | } |
| 1291 | |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 1292 | void SwitchQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1293 | { |
| 1294 | ValidateNumInputs(workloadInfo, "SwitchQueueDescriptor", 2); |
| 1295 | ValidateNumOutputs(workloadInfo, "SwitchQueueDescriptor", 2); |
| 1296 | |
| 1297 | std::vector<DataType> supportedTypes = { |
| 1298 | DataType::Float32, |
| 1299 | DataType::QuantisedAsymm8, |
| 1300 | DataType::QuantisedSymm16 |
| 1301 | }; |
| 1302 | |
| 1303 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], |
| 1304 | supportedTypes, |
| 1305 | "SwitchQueueDescriptor"); |
| 1306 | |
| 1307 | ValidateDataTypes(workloadInfo.m_InputTensorInfos[1], |
| 1308 | supportedTypes, |
| 1309 | "SwitchQueueDescriptor"); |
| 1310 | |
| 1311 | ValidateDataTypes(workloadInfo.m_OutputTensorInfos[0], |
| 1312 | supportedTypes, |
| 1313 | "SwitchQueueDescriptor"); |
| 1314 | |
| 1315 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 1316 | workloadInfo.m_OutputTensorInfos[0], |
| 1317 | "SwitchQueueDescriptor", |
| 1318 | "input0", |
| 1319 | "output0"); |
| 1320 | |
| 1321 | ValidateTensorShapesMatch(workloadInfo.m_InputTensorInfos[0], |
| 1322 | workloadInfo.m_OutputTensorInfos[1], |
| 1323 | "SwitchQueueDescriptor", |
| 1324 | "input0", |
| 1325 | "output1"); |
| 1326 | } |
| 1327 | |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 1328 | void PreCompiledQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const |
| 1329 | { |
| 1330 | // This is internally generated so it should not need validation. |
| 1331 | } |
| 1332 | |
Nattapat Chaimanowong | a0d2844 | 2018-11-21 16:48:17 +0000 | [diff] [blame] | 1333 | } //namespace armnn |