Example #1
0
        public GraphDef ToGraphDef()
        {
            TF_Buffer b      = this.ToGraphDefBuffer();
            var       stream = CodedInputStream.CreateWithLimits((UnmanagedMemoryStream)b, 256 * 1024 * 1024, 100);
            var       def    = GraphDef.Parser.ParseFrom(stream);

            b.Delete();
            return(def);
        }
Example #2
0
        private GraphDef _as_graph_def(bool add_shapes = false)
        {
            GraphDef def;

            using (var status = new Status())
                using (var buffer = ToGraphDef(status))
                {
                    status.Check(true);
                    // limit size to 250M, recursion to max 100
                    var inputStream = CodedInputStream.CreateWithLimits(buffer.DangerousMemoryBlock, 250 * 1024 * 1024, 100);
                    def = GraphDef.Parser.ParseFrom(inputStream);
                }

            // Strip the experimental library field iff it's empty.
            // if(def.Library.Function.Count == 0)

            return(def);
        }
Example #3
0
 public static GraphDef Import(string filePath) => GraphDef.Parser.ParseFrom(CodedInputStream.CreateWithLimits(File.OpenRead(filePath), 256 * 1024 * 1024, 100));