You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where x_i, y_i are (different) indices, and S_i are the strides of this shape. This is equivalent to:
(x_0 - y_0)*S_0 + (x_1 - y_1)*S_1 + ... == 0
We don't actually care what x_i and y_i are, so this is equivalent to:
x_0*S_0 + x_1*S_1 + x_2*S_2 + ... == 0
where x_i != 0. This is a linear diophantine equation, and we already have one solution at x_i = 0, so we just need to find other solutions, and check that they are in range.
This is pretty hard. Wikipedia research so far suggests we need to rewrite the equation as a system of linear diophantine equations, and then use the "Hermite normal form" to get the unbounded solutions, and then do some combinatoric search for the in-bounds solutions. This is an NP-hard problem, but the size of the problems are small, and I don't think these functions need to be fast.
is_subset_of is possibly similar.
The text was updated successfully, but these errors were encountered:
In order to determine if a shape maps two different indices to the same flat indices (i.e.
is_one_to_one
is false), we need to solve:where x_i, y_i are (different) indices, and S_i are the strides of this shape. This is equivalent to:
We don't actually care what x_i and y_i are, so this is equivalent to:
where x_i != 0. This is a linear diophantine equation, and we already have one solution at x_i = 0, so we just need to find other solutions, and check that they are in range.
This is pretty hard. Wikipedia research so far suggests we need to rewrite the equation as a system of linear diophantine equations, and then use the "Hermite normal form" to get the unbounded solutions, and then do some combinatoric search for the in-bounds solutions. This is an NP-hard problem, but the size of the problems are small, and I don't think these functions need to be fast.
is_subset_of
is possibly similar.The text was updated successfully, but these errors were encountered: