-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
area-System.Numerics.Tensorsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Milestone
Description
The output of this.Reshape currently can expose entries of the backing memory that aren't available on this, which to me seems a fatal flaw.
It feels like .Reshape was added to match numpy functionality (correct me if that's wrong), but it's behaving subtly differently and I don't think there is value in having it over requiring users to create explicit new tensors.
For example,
var a = new TensorSpan<double>(array: [0d, 1, 2, 3]); // [0, 1, 2, 3]
var b = a.Reshape(lengths: new IntPtr[] { 2, 2 }); // [[0, 1], [2, 3]]
var c = b.Slice(ranges: new NRange[] { ..2, ..1}); // [[0], [2]]
var d = c.Reshape(lengths: new IntPtr[] {2, 1}); // [[0], [1]]!!!
Console.WriteLine(d[new IntPtr[] { 1, 0 }]); // 1returns 1 whereas
import numpy as np
a = np.array([0, 1, 2, 3]) # [0, 1, 2, 3]
b = a.reshape([2, 2]) # [[0, 1], [2, 3]]
c = b[:2, :1] # [[0], [2]]
d = c.reshape([2, 1]) # [[0], [2]]
d[1, 0] # 2returns 2.
sinshu
Metadata
Metadata
Assignees
Labels
area-System.Numerics.Tensorsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged