示例#1
0
        public void Infer(Dequantize layer, DequantizeLayerArgument 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();
        }
示例#2
0
        public void Forward(DequantizeLayerArgument argument, ForwardContext context)
        {
            var src  = context.GetMainRamAt((int)argument.MainMemoryInputAddress);
            var dest = MemoryMarshal.Cast <byte, float>(context.GetMainRamAt((int)argument.MainMemoryOutputAddress));
            var q    = argument.QuantParam;

            for (int i = 0; i < argument.Count; i++)
            {
                dest[i] = src[i] * q.Scale + q.Bias;
            }
        }
示例#3
0
        public DequantizeLayerArgument DeserializeBin(int offset, K210BinDeserializeContext context)
        {
            var sr       = context.GetReaderAt(offset);
            var argument = new DequantizeLayerArgument();

            argument.Flags = sr.Read <K210LayerFlags>();
            argument.MainMemoryInputAddress  = sr.Read <uint>();
            argument.MainMemoryOutputAddress = sr.Read <uint>();
            argument.Count      = sr.Read <uint>();
            argument.QuantParam = sr.Read <K210QuantizationParam>();

            return(argument);
        }