Skip to content

Commit

Permalink
add inference of unknown dimension value
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenarnett committed Apr 21, 2021
1 parent e1112f3 commit cea2726
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions numba/misc/dummyarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,15 @@ def reshape(self, *newdims, **kws):
else:
knownsize *= dim

# compute the missing dimension
if unknownidx >= 0:
if knownsize == 0 or self.size % knownsize != 0:
raise ValueError("cannot infer valid shape for unknown dimension")
else:
newdims = newdims[0:unknownidx] \
+ tuple((self.size // knownsize,)) \
+ newdims[unknownidx + 1:]

newsize = functools.reduce(operator.mul, newdims, 1)

if order == 'A':
Expand Down

0 comments on commit cea2726

Please sign in to comment.