private static TypeProto MakeType(TypeProto typeProto, TensorProto.Types.DataType dataType, List<long> dims, List<bool> dimsParam) { Contracts.CheckValue(typeProto, nameof(typeProto)); if (typeProto.TensorType == null) typeProto.TensorType = new TypeProto.Types.Tensor(); typeProto.TensorType.ElemType = dataType; if (dims != null) { for (int index = 0; index < dims.Count; index++) { var d = new TensorShapeProto.Types.Dimension(); if (typeProto.TensorType.Shape == null) typeProto.TensorType.Shape = new TensorShapeProto(); if (dimsParam != null && dimsParam.Count > index && dimsParam[index]) d.DimParam = "None"; else d.DimValue = dims[index]; typeProto.TensorType.Shape.Dim.Add(d); } } return typeProto; }
public static TensorType From(TypeProto type) { return(new TensorType { ElementType = ParseElementType(type.TensorType.ElemType), Dimensions = ParseDimensions(type.TensorType.Shape.Dim) }); }
public static TypeProto Initialize(this TypeProto Type, string name, TypeProto.Types.Tensor t) { Type.Denotation = name; Type.TensorType = t; return(Type); }
public static TypeProto Initialize(this TypeProto type, TensorElementType d, params int[] dims) { type.TensorType = new TypeProto.Types.Tensor(); type.TensorType.Initialize(d, dims); return(type); }
public static ValueInfoProto Initialize(this ValueInfoProto ValueInfo, string name, TypeProto type) { ValueInfo.Name = name; ValueInfo.Type = type; return(ValueInfo); }
public static ValueInfoProto MakeTensorValueInfo(string name, TypeProto type) { return(new ValueInfoProto().Initialize(name, type)); }
public static string Print(this TypeProto type) { return(type.TensorType.Print()); }