public K210Conv2d(ReadOnlySpan <int> dimensions, K210Conv2dType conv2dType, Tensor <float> weights, Tensor <float> bias, K210PoolType poolType, ActivationFunctionType fusedActivationFunction, Layer nonTrivalActivation) { if (conv2dType == K210Conv2dType.DepthwiseConv2d && poolType != K210PoolType.None) { throw new ArgumentOutOfRangeException("Downsampling is not supported in dwConv2d."); } if (dimensions[2] < 4 || dimensions[3] < 4) { throw new ArgumentOutOfRangeException("Lower than 4x4 input is not supported in dwConv2d."); } if (nonTrivalActivation != null && fusedActivationFunction != ActivationFunctionType.Linear) { throw new ArgumentException("There should be only one activation in conv2d."); } Conv2dType = conv2dType; PoolType = poolType; FusedActivationFunction = fusedActivationFunction; NonTrivialActivation = nonTrivalActivation; Weights = weights; Bias = bias; var stride = GetStride(); if (dimensions[2] / stride < 4 || dimensions[3] / stride < 4) { throw new ArgumentOutOfRangeException("Lower than 4x4 output is not supported in dwConv2d."); } Input = AddInput("input", dimensions); Output = AddOutput("output", new[] { dimensions[0], OutputChannels, dimensions[2] / stride, dimensions[3] / stride }); }
public K210SeparableConv2d(ReadOnlySpan <int> dimensions, Tensor <float> dwWeights, Tensor <float> pwWeigths, Tensor <float> bias, K210PoolType poolType, ActivationFunctionType fusedActivationFunction) { if (dimensions[2] < 4 || dimensions[3] < 4) { throw new ArgumentOutOfRangeException("Lower than 4x4 input is not supported in dwConv2d."); } PoolType = poolType; FusedActivationFunction = fusedActivationFunction; DwWeights = dwWeights; PwWeights = pwWeigths; Bias = bias; var stride = GetStride(); if (dimensions[2] / stride < 4 || dimensions[3] / stride < 4) { throw new ArgumentOutOfRangeException("Lower than 4x4 output is not supported in dwConv2d."); } Input = AddInput("input", dimensions); Output = AddOutput("output", new[] { dimensions[0], OutputChannels, dimensions[2] / stride, dimensions[3] / stride }); }