public void Infer(ChannelwiseDequantize layer, ChannelwiseDequantizeLayerArgument argument, InferenceContext context) { var inputAlloc = context.MainMemoryMap[layer.Input.Connection.From]; var outputAlloc = context.MainMemoryMap[layer.Output]; argument.Flags = K210LayerFlags.MainMemoryOutput; argument.MainMemoryInputAddress = inputAlloc.GetAddress(); argument.MainMemoryOutputAddress = outputAlloc.GetAddress(); }
public ChannelwiseDequantizeLayerArgument Convert(ChannelwiseDequantize layer, ConvertContext context) { var q = context.Quantization.Distributions[layer.Input.Connection.From]; return(new ChannelwiseDequantizeLayerArgument { Channels = (uint)layer.Input.Dimensions[1], ChannelSize = (uint)(layer.Input.Dimensions.GetSize() / layer.Input.Dimensions[1]), QuantParams = context.Quantization.Distributions[layer.Input.Connection.From].Channels.Select(x => x.GetQuantizationParam(8)).ToArray() }); }
public override void Process(TransformContext context) { var conv2d = (K210Conv2d)context.MatchedLayers[0]; var dequantize = (Dequantize)context.MatchedLayers[1]; var output = dequantize.Output; conv2d.IsChannelwiseOutput = true; var channelwiseDeq = new ChannelwiseDequantize(conv2d.Output.Dimensions); channelwiseDeq.Input.SetConnection(conv2d.Output); var oldOuts = output.Connections.Select(o => o.To).ToList(); foreach (var oldOut in oldOuts) { oldOut.SetConnection(channelwiseDeq.Output); } }