示例#1
0
        public void Infer(TensorflowFlatten layer, TensorflowFlattenLayerArgument 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 TensorflowFlattenLayerArgument DeserializeBin(int offset, K210BinDeserializeContext context)
        {
            var sr       = context.GetReaderAt(offset);
            var argument = new TensorflowFlattenLayerArgument();

            argument.Flags = sr.Read <K210LayerFlags>();
            argument.MainMemoryInputAddress  = sr.Read <uint>();
            argument.MainMemoryOutputAddress = sr.Read <uint>();
            argument.Width    = sr.Read <uint>();
            argument.Height   = sr.Read <uint>();
            argument.Channels = sr.Read <uint>();

            return(argument);
        }
示例#3
0
        public void Forward(TensorflowFlattenLayerArgument argument, ForwardContext context)
        {
            var src  = MemoryMarshal.Cast <byte, float>(context.GetMainRamAt((int)argument.MainMemoryInputAddress));
            var dest = MemoryMarshal.Cast <byte, float>(context.GetMainRamAt((int)argument.MainMemoryOutputAddress));

            int i = 0;

            for (int oy = 0; oy < argument.Height; oy++)
            {
                for (int ox = 0; ox < argument.Width; ox++)
                {
                    for (int oc = 0; oc < argument.Channels; oc++)
                    {
                        dest[i++] = src[(int)((oc * argument.Height + oy) * argument.Width + ox)];
                    }
                }
            }
        }