04: Shapes
E0401
Sizes don’t match. Two sizes that must be equal can’t be: an argument’s axis and its parameter’s, a returned value’s and the return type’s, two axes that broadcast together, the axes @ contracts, a pattern’s name or number and the axis it binds, the parts of a pattern group and their axis. The notes say which axis and why, as in “?k is not known to equal 196”. A generic size or an unknown size is only equal to itself, so n doesn’t match 196 and ?k matches nothing else; use as to claim a size the checker can’t prove.
fn f(x: [n 3], w: [4 5]) = x @ w
See Unification and the size solver, Generic calls and Broadcasting by name.
E0402
Size isn’t divisible. A size divides by something that doesn’t divide it exactly: in a type or dim (D / 5), when solving a pattern group or a call ((gh 16) against 225), or in an extern fn’s rounded division with a size that isn’t known.
dim D = 768
fn f(x: [n D]) -> [n D / 5] = x
See Division, Solving and Rounded division.
E0403
Wrong number of axes. A tensor has a different number of axes than its parameter, the return type, the pattern side describing it, or the tensors it is joined with; @ got a tensor without axes; or there are more indices than axes.
fn f(x: [n D]) = rearrange(x, n -> n)
See Generic calls, Pattern operations and Indexing.
E0404
Axes can’t be lined up by name. Neither operand’s names are all axes of the other, so the axes line up from the right, and two named axes meet with different names. The same holds for the tensors of cat, stack, gather and scatter, which line up by position, and for a masked_fill mask with axes the tensor doesn’t have. If the axes really are the same, give them the same name with rearrange or as.
fn f(x: [n D], y: [k D]) = x + y
See The order rule.
E0405
Tensor has no such axis. over= names an axis the tensor doesn’t have, or a pattern’s output names an axis that isn’t in its input. The note lists the tensor’s named axes.
fn f(x: [n D]) = softmax(x, over=q)
See Built-in operations and Pattern operations.
E0406
Wrong arguments. Too many or too few arguments, an unknown keyword, an argument given twice, a missing or invalid over=, an unknown reduction, a bad index or slice bound, a keyword size for a pattern name that already has one, an Axis[..] argument that isn’t a name, a Size[..] argument that isn’t known statically, and so on.
fn f(x: [n D]) = softmax(x)
See Matching arguments and Built-in operations.
E0407
Pattern doesn’t fit the operation. An input name missing from the output of rearrange, repeat or split; a number on the right of -> that isn’t on the left; a name twice on one side; a nested group; a group or number in einsum; a pattern operation without a pattern or with two; split without exactly one number that gives the count.
fn f(x: [b n D]) = rearrange(x, b n D -> b D)
See Pattern operations.
E0408
Axes in a different order. A pattern names an axis by a name the operand has at another position. Patterns bind by position, so this is probably a transposition; reorder the axes with rearrange first.
fn f(x: [b n D]) = rearrange(x, b D n -> b n D)
See Pattern operations.
E0409
Size can’t be inferred. The size solver is left with unknowns that no equation determines: two new names in one pattern group, a new axis in repeat without a size, or a call whose argument doesn’t determine a grouped parameter’s parts. Give all but one of them a size, as in h=8.
dim D = 768
fn f(x: [b n D]) = rearrange(x, b n (h e) -> b n h e)
See Solver failures and Pattern operations.
E0410
as that can never succeed. The asserted shape has a different number of axes or a different known size, the asserted domain contradicts what’s known about the values, or the asserted dtype is of another kind. An as claims what the checker can’t prove, but not what it can disprove.
dim D = 768
fn f(x: [n D]) = x as [n 5]
See Assertions with as.
E0411
Wrong number of results. split and topk give several results, which must be bound to as many names, and a single value can’t be bound to several names.
fn f(x: [n 12]) -> [n 4]:
a, b = split(x, n (3 e) -> n e)
return a
See Statements and Pattern operations.
E0412
Value isn’t a tensor. A string, or the several results of split before they are named, where a tensor is needed.
fn f(x: [n]) = x + "s"
See Operators.
E0413
Python value with an unknown shape. A Python value is used where its shape or type must be known: returned as a typed result, passed as a tensor argument, given to a pattern operation or an operation along a named axis, or converted with to and a domain. Assert its type with as first.
import python torch
fn f() -> [8] = torch.ones(8)
See Python interop.
E0414
Size too large. A size, or a step in working one out, doesn’t fit in 128 bits.
dim Big = 4294967296 * 4294967296 * 4294967296 * 4294967296 * 4294967296
See Size polynomials.
E0415
More elements than the axis has. topk asks for more values than its axis has, or a negative number.
dim C = 10
fn f(x: [b C]) -> [b C]:
v, i = topk(x, 11, over=C)
return x
See Built-in operations.