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,
LayerType GetType() const
virtual const TensorInfo & GetTensorInfo() const =0
char const * GetLayerTypeAsCString(LayerType type)
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
void ValidateTensorShapesFromInputs() override
const TensorShape & GetShape() const
const TensorInfo & GetTensorInfo() const override
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
ElementwiseBaseLayer(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
const InputSlot & GetInputSlot(unsigned int index) const override