12 #include <boost/assert.hpp> 19 :
Layer(numInputSlots, numOutputSlots, type, name)
25 BOOST_ASSERT(inputShapes.size() == 2);
26 auto& input0 = inputShapes[0];
27 auto& input1 = inputShapes[1];
30 BOOST_ASSERT(input0.GetNumDimensions() == input1.GetNumDimensions());
31 unsigned int numDims = input0.GetNumDimensions();
32 std::vector<unsigned int> dims(numDims);
34 for (
unsigned int i = 0; i < numDims; i++)
36 unsigned int dim0 = input0[i];
37 unsigned int dim1 = input1[i];
41 BOOST_ASSERT_MSG(dim0 == dim1 || dim0 == 1 || dim1 == 1,
42 "Dimensions should either match or one should be of size 1.");
45 dims[i] = std::max(dim0, dim1);
48 return std::vector<TensorShape>({
TensorShape(numDims, dims.data()) });
60 BOOST_ASSERT(inferredShapes.size() == 1);
63 msg +=
"Layer: TensorShape set on OutputSlot[0] does not match the inferred shape.";
64 ConditionalThrowIfNotEqual<LayerValidationException>(msg,
const TensorShape & GetShape() const
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
By default returns inputShapes if the number of inputs are equal to number of outputs, otherwise infers the output shapes from given input shapes and layer properties.
Copyright (c) 2020 ARM Limited.
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
char const * GetLayerTypeAsCString(LayerType type)
ElementwiseBaseLayer(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
LayerType GetType() const
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
virtual const TensorInfo & GetTensorInfo() const =0
const TensorInfo & GetTensorInfo() const override
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of the element wise operation...