示例#1
0
        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;
        }
示例#2
0
 public static TensorType From(TypeProto type)
 {
     return(new TensorType
     {
         ElementType = ParseElementType(type.TensorType.ElemType),
         Dimensions = ParseDimensions(type.TensorType.Shape.Dim)
     });
 }
示例#3
0
 public static TypeProto Initialize(this TypeProto Type, string name, TypeProto.Types.Tensor t)
 {
     Type.Denotation = name;
     Type.TensorType = t;
     return(Type);
 }
示例#4
0
 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);
 }
示例#5
0
 public static ValueInfoProto Initialize(this ValueInfoProto ValueInfo, string name, TypeProto type)
 {
     ValueInfo.Name = name;
     ValueInfo.Type = type;
     return(ValueInfo);
 }
示例#6
0
 public static ValueInfoProto MakeTensorValueInfo(string name, TypeProto type)
 {
     return(new ValueInfoProto().Initialize(name, type));
 }
示例#7
0
 public static string Print(this TypeProto type)
 {
     return(type.TensorType.Print());
 }