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; }
internal static void SetDim(TensorShapeProto.Types.Dimension dim, DimParamOrValue dimParamOrValue) { dim.ClearValue(); if (dimParamOrValue.IsParam) { dim.DimParam = dimParamOrValue.Param; } else { dim.DimValue = dimParamOrValue.Value; } }