forked from M-Labs/artiq
1
0
Fork 0
artiq/artiq/compiler
David Nadlinger 5ba22c11c3 compiler: Change type inference rules for empty array() calls
array([...]), the constructor for NumPy arrays, currently has the
status of some weird kind of macro in ARTIQ Python, as it needs
to determine the number of dimensions in the resulting array
type, which is a fixed type parameter on which inference cannot
be performed.

This leads to an ambiguity for empty lists, which could contain
elements of arbitrary type, including other lists (which would
add to the number of dimensions).

Previously, I had chosen to make array([]) to be of completely
indeterminate type for this reason. However, this is different
to how the call behaves in host NumPy, where this is a well-formed
call creating an empty 1D array (or 2D for array([[], []]), etc.).

This commit adds special matching for (recursive lists of) empty
ListT AST nodes to treat them as scalar dimensions, with the
element type still unknown.

This also happens to fix type inference for embedding empty 1D
NumPy arrays from host object attributes, although multi-dimensional
arrays will still require work (see GitHub #1633).

GitHub: Fixes #1626.
2021-03-14 22:48:43 +00:00
..
algorithms compiler: do not associate SSA values with iodelay even when inlining. 2015-12-25 15:02:33 +08:00
analyses compiler: Constness is a validator, not analysis. 2017-06-09 07:29:31 +00:00
testbench use tokenize.open() to open Python source files 2018-07-07 17:04:56 +08:00
transforms compiler: Change type inference rules for empty array() calls 2021-03-14 22:48:43 +00:00
validators compiler: T{C -> External}Function, clarify docs [nfc] 2020-08-09 03:54:41 +01:00
__init__.py compiler: pull in dependencies in more finely grained way (fixes #181). 2015-11-24 17:32:04 +08:00
asttyped.py compiler: allow specifying per-function "fast-math" flags. 2016-03-28 21:44:08 +00:00
builtins.py compiler: Change type inference rules for empty array() calls 2021-03-14 22:48:43 +00:00
embedding.py compiler: Linguistically untangle comment [nfc] 2021-03-14 18:40:21 +00:00
import_cache.py import_cache: make sure last line ends with \n as linecache does. Closes #547 2016-09-02 11:01:28 +08:00
iodelay.py compiler.iodelay: correctly fold max(0, [0, ]...). 2015-11-24 00:46:55 +08:00
ir.py compiler/firmware: RPCs for ndarrays 2020-08-09 17:08:43 +01:00
math_fns.py compiler: Provide libm special functions (erf, Bessel functions, …) 2020-11-11 19:15:30 +01:00
module.py compiler: Raise AssertionErrors instead of abort()ing on all targets 2020-11-10 20:40:18 +01:00
prelude.py compiler: remove obsolete watchdog code (#1458) 2020-12-08 13:25:08 +08:00
targets.py Revert "compiler: enabled vectorize option" 2021-01-11 19:43:12 +08:00
types.py compiler: Implement broadcasting of math functions 2020-08-09 03:54:42 +01:00