Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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()
            });
        }
Exemplo n.º 3
0
        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);
            }
        }