Beispiel #1
0
        public static TensorShapeProto as_shape <T>(T[] dims)
        {
            TensorShapeProto shape = new TensorShapeProto();

            for (int i = 0; i < dims.Length; i++)
            {
                var dim = new TensorShapeProto.Types.Dim();
                switch (dims[i])
                {
                case int n:
                    dim.Size = n;
                    break;

                case long l:
                    dim.Size = l;
                    break;

                default:
                    throw new NotImplementedException("as_shape Not Implemented");
                }
                // dim.Name = $"dim_{i}";

                shape.Dim.Add(dim);
            }

            return(shape);
        }
Beispiel #2
0
        public static TensorShapeProto as_proto(this Shape tshape)
        {
            TensorShapeProto shape = new TensorShapeProto();

            for (int i = 0; i < tshape.ndim; i++)
            {
                var dim = new TensorShapeProto.Types.Dim();
                dim.Size = tshape.dims[i];
                //dim.Name = $"dim_{i}";

                shape.Dim.Add(dim);
            }

            return(shape);
        }
Beispiel #3
0
        public static TensorShapeProto as_shape(long[] dims)
        {
            TensorShapeProto shape = new TensorShapeProto();

            for (int i = 0; i < dims.Length; i++)
            {
                var dim = new TensorShapeProto.Types.Dim();
                dim.Size = dims[i];
                dim.Name = $"dim_{i}";

                shape.Dim.Add(dim);
            }

            return(shape);
        }