From 1dc83febfb76d6a770bdf3ba16c4034a970c2320 Mon Sep 17 00:00:00 2001 From: Nikhil Raj Date: Thu, 16 May 2024 09:47:51 +0100 Subject: IVGCVSW-8260 Update Doxgen Docu for 24.05 Signed-off-by: Nikhil Raj Change-Id: If4bc983bf2793a27ded8e26ac2b29523fc1e4711 --- latest/_batch_mat_mul_layer_8cpp_source.html | 169 ++++++++++++++------------- 1 file changed, 89 insertions(+), 80 deletions(-) (limited to 'latest/_batch_mat_mul_layer_8cpp_source.html') diff --git a/latest/_batch_mat_mul_layer_8cpp_source.html b/latest/_batch_mat_mul_layer_8cpp_source.html index d3bdc9bf10..15d9d79d16 100644 --- a/latest/_batch_mat_mul_layer_8cpp_source.html +++ b/latest/_batch_mat_mul_layer_8cpp_source.html @@ -36,7 +36,7 @@ ArmNN
-  24.02 +  24.05
@@ -97,7 +97,7 @@ $(document).ready(function(){initNavTree('_batch_mat_mul_layer_8cpp_source.html'
Go to the documentation of this file.
1 //
-
2 // Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
+
2 // Copyright © 2022-2024 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "BatchMatMulLayer.hpp"
@@ -130,96 +130,104 @@ $(document).ready(function(){initNavTree('_batch_mat_mul_layer_8cpp_source.html'
32 
33 std::vector<TensorShape> BatchMatMulLayer::InferOutputShapes(const std::vector<TensorShape>& inputShapes) const
34 {
-
35  ARMNN_ASSERT(inputShapes.size() == 2);
-
36 
-
37  TensorShape inputXShape = inputShapes[0];
-
38  TensorShape inputYShape = inputShapes[1];
-
39 
-
40  // Adjoint is assumed to be square, but we will apply the permute anyway
- -
42  {
- -
44  inputXShape);
-
45  inputXShape = armnnUtils::Permuted(inputXShape, permuteVec);
-
46  }
- -
48  {
- -
50  inputYShape);
-
51  inputYShape = armnnUtils::Permuted(inputYShape, permuteVec);
-
52  }
-
53 
-
54  TensorShape& longerInput = inputXShape.GetNumDimensions() >= inputYShape.GetNumDimensions()?
-
55  inputXShape : inputYShape;
-
56  TensorShape& shorterInput = inputXShape.GetNumDimensions() >= inputYShape.GetNumDimensions()?
-
57  inputYShape : inputXShape;
-
58 
-
59  unsigned int inputNumDimsOffset = longerInput.GetNumDimensions() - shorterInput.GetNumDimensions();
-
60 
-
61  unsigned int outputNumDimensions = longerInput.GetNumDimensions();
+
35  if (inputShapes.size() != 2)
+
36  {
+
37  throw armnn::LayerValidationException("inputShapes' size is \"" + std::to_string(inputShapes.size()) +
+
38  "\" - should be \"2\".");
+
39  }
+
40 
+
41  TensorShape inputXShape = inputShapes[0];
+
42  TensorShape inputYShape = inputShapes[1];
+
43 
+
44  // Adjoint is assumed to be square, but we will apply the permute anyway
+ +
46  {
+ +
48  inputXShape);
+
49  inputXShape = armnnUtils::Permuted(inputXShape, permuteVec);
+
50  }
+ +
52  {
+ +
54  inputYShape);
+
55  inputYShape = armnnUtils::Permuted(inputYShape, permuteVec);
+
56  }
+
57 
+
58  TensorShape& longerInput = inputXShape.GetNumDimensions() >= inputYShape.GetNumDimensions()?
+
59  inputXShape : inputYShape;
+
60  TensorShape& shorterInput = inputXShape.GetNumDimensions() >= inputYShape.GetNumDimensions()?
+
61  inputYShape : inputXShape;
62 
-
63  std::vector<unsigned int> tensorDimensions(outputNumDimensions, 0);
+
63  unsigned int inputNumDimsOffset = longerInput.GetNumDimensions() - shorterInput.GetNumDimensions();
64 
-
65  const auto& longerInputDataLayout = inputXShape.GetNumDimensions() >= inputYShape.GetNumDimensions()?
- -
67  auto longerAxesToMul = BatchMatMulDescriptor::GetAxesToMul(longerInputDataLayout,
-
68  longerInput);
-
69 
-
70  for (unsigned int i = 0; i < outputNumDimensions; ++i)
-
71  {
-
72  if (i == longerAxesToMul.first)
-
73  {
-
74  tensorDimensions[i] = &shorterInput == &inputXShape ? inputXShape[i - inputNumDimsOffset] : inputXShape[i];
-
75  }
-
76  else if(i == longerAxesToMul.second)
+
65  unsigned int outputNumDimensions = longerInput.GetNumDimensions();
+
66 
+
67  std::vector<unsigned int> tensorDimensions(outputNumDimensions, 0);
+
68 
+
69  const auto& longerInputDataLayout = inputXShape.GetNumDimensions() >= inputYShape.GetNumDimensions()?
+ +
71  auto longerAxesToMul = BatchMatMulDescriptor::GetAxesToMul(longerInputDataLayout,
+
72  longerInput);
+
73 
+
74  for (unsigned int i = 0; i < outputNumDimensions; ++i)
+
75  {
+
76  if (i == longerAxesToMul.first)
77  {
-
78  tensorDimensions[i] = &shorterInput == &inputYShape ? inputYShape[i - inputNumDimsOffset] : inputYShape[i];
+
78  tensorDimensions[i] = &shorterInput == &inputXShape ? inputXShape[i - inputNumDimsOffset] : inputXShape[i];
79  }
-
80  else // The other dimensions not to be multiplied (but may be broadcasted)
+
80  else if(i == longerAxesToMul.second)
81  {
-
82  // Does NOT validate whether it's a valid broadcast - that's done in the validate func in WorkloadData.cpp
-
83  tensorDimensions[i] = static_cast<int>(i) - static_cast<int>(inputNumDimsOffset) < 0 ?
-
84  longerInput[i] :
-
85  std::max(longerInput[i], shorterInput[i - inputNumDimsOffset]);
-
86  }
-
87  }
-
88 
-
89  auto outputShape = TensorShape(outputNumDimensions, tensorDimensions.data());
-
90  return std::vector<TensorShape>({ outputShape });
-
91 }
+
82  tensorDimensions[i] = &shorterInput == &inputYShape ? inputYShape[i - inputNumDimsOffset] : inputYShape[i];
+
83  }
+
84  else // The other dimensions not to be multiplied (but may be broadcasted)
+
85  {
+
86  // Does NOT validate whether it's a valid broadcast - that's done in the validate func in WorkloadData.cpp
+
87  tensorDimensions[i] = static_cast<int>(i) - static_cast<int>(inputNumDimsOffset) < 0 ?
+
88  longerInput[i] :
+
89  std::max(longerInput[i], shorterInput[i - inputNumDimsOffset]);
+
90  }
+
91  }
92 
- -
94 {
- +
93  auto outputShape = TensorShape(outputNumDimensions, tensorDimensions.data());
+
94  return std::vector<TensorShape>({ outputShape });
+
95 }
96 
-
97  const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
-
98 
- + +
98 {
+
100 
-
101  auto inferredShapes = InferOutputShapes({
- - +
101  const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
+
102 
+
104 
-
105  ARMNN_ASSERT(inferredShapes.size() == 1);
-
106 
-
107  ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "BatchMatMulLayer");
-
108 }
-
109 
-
110 } // namespace armnn
+
105  auto inferredShapes = InferOutputShapes({
+ + +
108 
+
109  if (inferredShapes.size() != 1)
+
110  {
+
111  throw armnn::LayerValidationException("inferredShapes has "
+
112  + std::to_string(inferredShapes.size()) +
+
113  " elements - should only have 1.");
+
114  }
+
115 
+
116  ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "BatchMatMulLayer");
+
117 }
+
118 
+
119 } // namespace armnn
-
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
bool m_TransposeX
Transpose the slices of each input tensor Transpose and Adjoint can not both be set to true for the s...
-
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:92
+
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:100
bool m_AdjointX
Adjoint the slices of each input tensor Transpose and Adjoint can not both be set to true for the sam...
-
static std::pair< unsigned int, unsigned int > GetAxesToMul(DataLayout dataLayout, const TensorShape &tensorShape)
Static helper to get the two axes (for each input) for multiplication.
-
void ValidateTensorShapesFromInputs() override
Check if the input tensor shapes will lead to a valid configuration of BatchMatMulLayer.
+
static std::pair< unsigned int, unsigned int > GetAxesToMul(DataLayout dataLayout, const TensorShape &tensorShape)
Static helper to get the two axes (for each input) for multiplication.
+
void ValidateTensorShapesFromInputs() override
Check if the input tensor shapes will lead to a valid configuration of BatchMatMulLayer.
DataLayout m_DataLayoutX
Data layout of each input tensor, such as NHWC/NDHWC (leave as default for arbitrary layout)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
-
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
Definition: Layer.cpp:435
-
static PermutationVector GetPermuteVec(DataLayout dataLayout, const TensorShape &tensorShape)
Static helper to get the axes which will be transposed.
+
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
Definition: Layer.cpp:457
+
static PermutationVector GetPermuteVec(DataLayout dataLayout, const TensorShape &tensorShape)
Static helper to get the axes which will be transposed.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:339
BatchMatMulLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
@@ -228,19 +236,20 @@ $(document).ready(function(){initNavTree('_batch_mat_mul_layer_8cpp_source.html'
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:332
-
const TensorInfo & GetTensorInfo() const override
Gets the TensorInfo for this InputSlot.
Definition: Layer.cpp:592
+
const TensorInfo & GetTensorInfo() const override
Gets the TensorInfo for this InputSlot.
Definition: Layer.cpp:614
BatchMatMulDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *Layer::CreateWorkload.
+
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
Infers the output shape from the given input shapes.
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the BatchMatMul type.
-
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
Definition: Layer.cpp:504
+
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
Definition: Layer.cpp:526
A BatchMatMulDescriptor for the BatchMatMul operator.
-
void SetAdditionalInfo(QueueDescriptor &descriptor) const
Definition: Layer.cpp:287
+
void SetAdditionalInfo(QueueDescriptor &descriptor) const
Definition: Layer.cpp:303
@@ -248,7 +257,7 @@ $(document).ready(function(){initNavTree('_batch_mat_mul_layer_8cpp_source.html'
Copyright (c) 2021 ARM Limited and Contributors.
BatchMatMulLayer(const BatchMatMulDescriptor &param, const char *name)
Constructor to create a BatchMatMulLayer.
-
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:391
+
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:410
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:441
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
Definition: Types.hpp:491
@@ -258,7 +267,7 @@ $(document).ready(function(){initNavTree('_batch_mat_mul_layer_8cpp_source.html'