Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Appendix A: Diagnostics

Every error, warning and hint the checker reports has a code. Errors start with E, warnings with W and hints with H; the first two digits say which part of the language it’s about. This appendix lists them all, each linked to its section in the language reference, which explains it with a short program that produces it.

From the command line, shapescript explain E0401 prints the same section. In the editor, each diagnostic’s code is a link to it.

The ones you’ll meet most are E0401 (sizes that don’t match), E0403 (the wrong number of axes), E0404 (axes that don’t line up by name) and E0501 (a value that doesn’t fit a domain).

Lexical structure

CodeMeaning
E0101Unexpected character
E0102Unterminated string
E0103Tab used for indentation
E0104Indentation doesn’t match an enclosing block
E0105Unmatched closing bracket
E0106Unclosed bracket

Syntax

CodeMeaning
E0201Expected a different token
E0202Unexpected indentation
E0203Pattern outside a pattern operation
E0204Invalid pipe stage
E0205Misused _
E0206Chained comparison
E0207Expected a declaration
E0208Integer too large
W0201Doc comment not attached to a declaration

Names and declarations

CodeMeaning
E0301Unknown name
E0302Name defined twice
E0303Name used as the wrong kind of thing
E0304Dim defined in terms of itself
E0305Dim isn’t a positive whole number
E0306Invalid function signature
E0307Missing return
E0308Invalid extern fn

Shapes and sizes

CodeMeaning
E0401Sizes don’t match
E0402Size isn’t divisible
E0403Wrong number of axes
E0404Axes can’t be lined up by name
E0405Tensor has no such axis
E0406Wrong arguments
E0407Pattern doesn’t fit the operation
E0408Axes in a different order
E0409Size can’t be inferred
E0410as that can never succeed
E0411Wrong number of results
E0412Value isn’t a tensor
E0413Python value with an unknown shape
E0414Size too large
E0415More elements than the axis has

Value domains and dtypes

CodeMeaning
E0501Value isn’t in the expected domain
E0502Wrong dtype
E0503Invalid domain
E0504to conversion that doesn’t exist
E0505Arithmetic on a mask
E0506Function applied outside its domain
E0507Indices for an axis of a different size
W0501Value can be exactly where a function is undefined

Math in comments

CodeMeaning
H0601LaTeX outside the supported subset
H0602Malformed math in a comment

Notebooks

CodeMeaning
E0701Something from a notebook cell that has to run again

Control flow and host scalars

CodeMeaning
E0801Value assigned in a loop or if changes its type
E0802if on something other than a bool
E0803Range whose ends aren’t ints
E0804for over something that can’t be looped over
E0805Tensor where an int, float or bool is expected

Models

CodeMeaning
E0901Model has no such field
E0902Invalid model field
E0903Invalid field initializer
E0904Value isn’t the expected model

Devices

CodeMeaning
E1001Invalid devices declaration
E1002Unknown devices option
E1003Devices declared more than once
E1004devices after other declarations
E1005Standalone build without devices
E1006--devices disagrees with the file’s devices

mut and gradients

CodeMeaning
E1101mut where it isn’t allowed
E1102Change to something not passed as mut
E1103Argument for a mut parameter without mut
E1104New value for a mut parameter
E1105Function that can’t be differentiated
E1106Gradient of something that isn’t a []
E1107Gradient of a function that doesn’t read the model
E1108Operation that gradients don’t have
W1101Param that a differentiated function never reads

Modes

CodeMeaning
E1201Call without its Mode
E1202Value isn’t a Mode

Data and datasets

CodeMeaning
E1301Data record has no such field
E1302Invalid data field
E1303Value isn’t the expected data
E1304Invalid dataset stage

Logs and sinks

CodeMeaning
E1401Logs record has no such metric
E1402Invalid logs metric
E1403Value isn’t the expected logs record
E1404Value isn’t a LogSink

Optimizers

CodeMeaning
E1501Optimizer that isn’t given a model
E1502Optimizer state or gradient of another model
E1503Value isn’t the expected optimizer state
E1504Learning rate that isn’t a number or a Schedule
E1505update or a gradient transform given the wrong kind of value

Checkpoints

CodeMeaning
E1601Value that save can’t write to a checkpoint
E1602load given something that isn’t a type it can read
E1603Checkpoint path that isn’t a string

Export

CodeMeaning
E1701Python in an exported function
E1702extern fn outside torch, called by an exported function
E1703as on a Python value in an exported function
E1704Value or operation with no torch-only lowering in an exported function
E1705Parameter of an export fn that isn’t a tensor with a shape
E1706return inside an if on a tensor in an exported function

Several devices

CodeMeaning
E1801Operation across the batch axis with no lowering for several devices
E1802Batch axis that can’t stay split across the devices
E1803Device work in a function that runs in the controller
E1804Whole value passed where a function takes a split one
E1805Standalone build for several devices

Options for several devices

CodeMeaning
E1901Python call given data split across the devices
E1902Split axis whose size the devices don’t divide
E1903devices option given twice
E1904split of something other than a dim

Fixed shapes and padding

CodeMeaning
H2001The last batch isn’t padded

Grouped sizes and shape aliases

CodeMeaning
E2201Shape alias defined in terms of itself
E2202Shape alias where its axes can’t be spliced
E2203Grouped size like 16gh outside an axis
H220116 gh, two axes, where 16gh was probably meant

Modules and generic functions

CodeMeaning
E2301No .ss file for an import
E2302Files that import each other
E2303An imported file has errors
E2304A name an imported file doesn’t declare
E2305Standalone build of a file with imports
E2306An import or generic function where it can’t be used
E2307Functions of the same name for the same model
E2308No function of that name for the argument’s model
E2309Misused type variable
E2310Arguments disagree about a type variable
E2311A generic function needs a function the model doesn’t have
E2312A generic function doesn’t check with these types
E2313Generic functions call each other too deeply

Iterator chains: what they iterate and their independence

CodeMeaning
E2401Iteration over something that isn’t an axis or a tensor
E2402Iterator stage that reads the result it builds
E2403Iterator stage whose function does more than compute a value
E2404Iterator stage that uses values split across devices
H2401Sequential loop whose iterations are independent

Python modules for .ss files

CodeMeaning
W2501A hand-written module has the generated module’s name

Packages

CodeMeaning
E2901An installed package built by a newer ShapeScript

Iterator chains: syntax and stages

CodeMeaning
E3201Comprehension, which iterator chains replaced
E3202Lambda outside an iterator stage
E3203Range outside an iterator chain or a loop
E3204zip of iterations of different sizes
E3205Pairs from zip or enumerate used as a value
E3206Invalid function of map or filter