MCPcopy Create free account
hub / github.com/ARM-software/armnn / ValidateAndCopyShape

Method ValidateAndCopyShape

src/armnn/Layer.cpp:457–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455}
456
457void Layer::ValidateAndCopyShape(const TensorShape& outputShape,
458 const TensorShape& inferredShape,
459 const ShapeInferenceMethod shapeInferenceMethod,
460 const std::string& layerName,
461 const unsigned int outputSlotIndex)
462{
463 if (shapeInferenceMethod == ShapeInferenceMethod::ValidateOnly)
464 {
465 if (m_AllowExpandedDims)
466 {
467 std::vector<unsigned int> outputDims = armnnUtils::SqueezeDims(outputShape);
468 std::vector<unsigned int> inferredDims = armnnUtils::SqueezeDims(inferredShape);
469
470 if (outputDims.size() != inferredDims.size())
471 {
472 std::stringstream ss;
473 ss << layerName << ": TensorShape set on OutputSlot[" << outputSlotIndex <<
474 "] does not match the inferred shape. ";
475 ss << outputShape << " != " << inferredShape;
476 throw LayerValidationException(ss.str());
477 }
478 for (unsigned int i = 0; i < outputDims.size(); ++i)
479 {
480 if (outputDims[i] != inferredDims[i])
481 {
482 std::stringstream ss;
483 ss << layerName << ": TensorShape set on OutputSlot[" << outputSlotIndex <<
484 "] does not match the inferred shape at dimension index [";
485 ss << i << "] " << outputShape << " != " << inferredShape;
486 throw LayerValidationException(ss.str());
487 }
488 }
489 return;
490 }
491 else
492 {
493 ConditionalThrowIfNotEqual<LayerValidationException>(
494 layerName + ": TensorShape set on OutputSlot[0] does not match the inferred shape.",
495 outputShape,
496 inferredShape);
497 return;
498 }
499 }
500
501 if (outputShape.GetDimensionality() == Dimensionality::Specified)
502 {
503 for (unsigned int i = 0; i < outputShape.GetNumDimensions(); ++i)
504 {
505 if (outputShape.GetDimensionSpecificity(i) && outputShape[i] != inferredShape[i])
506 {
507 std::stringstream ss;
508 ss << layerName << ": TensorShape set on OutputSlot[" << outputSlotIndex <<
509 "] does not match the inferred shape at dimension index [";
510 ss << i << "] " << outputShape << " != " << inferredShape;
511 throw LayerValidationException(ss.str());
512 }
513 }
514 }

Callers

nothing calls this directly

Calls 10

SqueezeDimsFunction · 0.85
GetDimensionalityMethod · 0.80
sizeMethod · 0.45
strMethod · 0.45
GetNumDimensionsMethod · 0.45
GetDataTypeMethod · 0.45
GetQuantizationScaleMethod · 0.45
GetQuantizationOffsetMethod · 0.45
SetTensorInfoMethod · 0.45

Tested by

no test coverage detected