1
0
forked from M-Labs/nac3
Commit Graph

408 Commits

Author SHA1 Message Date
7f3c45302d core/ndstrides: update builtin_fns to use ndarray with strides 2024-10-18 15:01:54 +08:00
3a12d39548 core/ndstrides: add NDArrayObject::to_any 2024-10-18 15:01:54 +08:00
618854f8d0 core/ndstrides: add ContiguousNDArray
Currently this is used to interop with nalgebra.
2024-10-18 15:01:54 +08:00
693b7f3774 core/ndstrides: implement np_dot() for scalars and 1D 2024-10-18 15:01:29 +08:00
73c2203b89 core/ndstrides: implement general matmul 2024-10-18 15:01:25 +08:00
56cccce149 core/ndstrides: implement cmpop 2024-10-18 14:59:52 +08:00
bb992704b2 core/ndstrides: implement unary op 2024-10-18 14:59:52 +08:00
9e40c83490 core/ndstrides: implement binop 2024-10-18 14:59:52 +08:00
fbfc0b293a core/ndstrides: add NDArrayOut, broadcast_map and map 2024-10-18 14:59:52 +08:00
5bed394ef7 core/ndstrides: implement subscript assignment
Overlapping is not handled. Currently it has undefined behavior.
2024-10-18 14:58:58 +08:00
f731e604c7 core/ndstrides: add more ScalarOrNDArray and NDArrayObject utils 2024-10-18 14:58:58 +08:00
052b67c8e9 core/ndstrides: implement np_transpose() (no axes argument)
The IRRT implementation knows how to handle axes. But the argument is
not in NAC3 yet.
2024-10-18 14:58:29 +08:00
9359ed9685 core/ndstrides: implement broadcasting & np_broadcast_to() 2024-10-18 14:57:33 +08:00
926e7e93a8 core/ndstrides: implement np_reshape() 2024-10-18 14:56:24 +08:00
40c2448651 core/ndstrides: implement np_shape() and np_strides()
These functions are not important, but they are handy for debugging.

`np.strides()` is not an actual NumPy function, but `ndarray.strides` is used.
2024-10-18 14:54:04 +08:00
18db85fa7b core/ndstrides: implement ndarray.fill() and .copy() 2024-10-18 14:21:57 +08:00
fa047d505d core/ndstrides: implement np_identity() and np_eye() 2024-10-18 14:21:57 +08:00
8f0084ac8a core/ndstrides: implement np_array()
It also checks for inconsistent dimensions if the input is a list.
e.g., rejecting `[[1.0, 2.0], [3.0]]`.

However, currently only `np_array(<input>, copy=False)` and `np_array(<input>, copy=True)` are supported. In NumPy, copy could be false, true, or None. Right now, NAC3's `np_array(<input>, copy=False)` behaves like NumPy's `np.array(<input>, copy=None)`.
2024-10-18 14:21:50 +08:00
9cfa2622ca core/ndstrides: add NDArrayObject::atleast_nd 2024-10-18 14:21:50 +08:00
b6980c3a39 core/ndstrides: add NDArrayObject::make_copy 2024-10-18 14:21:50 +08:00
8f9d2d82dd core/ndstrides: implement ndarray indexing
The functionality for `...` and `np.newaxis` is there in IRRT, but there
is no implementation of them for @kernel Python expressions because of
M-Labs/nac3#486.
2024-10-18 14:21:42 +08:00
54a842a93f core/ndstrides: implement len(ndarray) & refactor len() 2024-10-18 14:21:28 +08:00
792374fa9a core/ndstrides: implement np_{zeros,ones,full,empty} 2024-10-18 14:21:28 +08:00
b41d091cac core/model: add util::gen_for_model 2024-10-18 14:21:27 +08:00
79eda92582 core/object: add ListObject and TupleObject
Needed for implementing other ndarray utils.
2024-10-18 14:21:27 +08:00
50f960abb5 core/ndstrides: implement ndarray iterator NDIter
A necessary utility to iterate through all elements in a possibly strided ndarray.
2024-10-18 14:21:27 +08:00
a0a1f35b5d core/ndstrides: introduce NDArray
NDArray with strides.
2024-10-18 14:21:27 +08:00
572ae116ec core/object: introduce object
A small abstraction to simplify implementations.
2024-10-18 14:21:26 +08:00
870a922367 [core] introduce models 2024-10-18 14:21:04 +08:00
b6cd2a6993 [meta] Reorganize order of use declarations - Phase 3 2024-10-17 16:25:52 +08:00
a98f33e6d1 [meta] Reorganize order of use declarations - Phase 2
Some more rules:

- For module-level imports, prefer no prefix > super > crate.
- Use crate instead of super if super refers to the crate-level module
2024-10-17 15:57:33 +08:00
2bb788e4bb [core] codegen/expr: Materialize implicit globals
Required for when globals are read without the use of a global
declaration.
2024-10-07 13:13:20 +08:00
e60e8e837f [core] Add support for global statements 2024-10-04 13:24:27 +08:00
9fdbe9695d [core] Add generator to SymbolResolver::get_symbol_value
Needed in a future commit.
2024-10-04 13:20:29 +08:00
192290889b [core] Add IdentifierInfo
Keeps track of whether an identifier refers to a global or local
variable.
2024-10-04 13:20:24 +08:00
c7697606e1 [core] Add TopLevelDef::Variable 2024-10-04 13:09:25 +08:00
a43b59539c [meta] Move variables declarations closer to where they are first used 2024-10-04 13:00:16 +08:00
fe06b2806f [meta] Reorganize order of use declarations
Use declarations are now grouped into 4 groups:

- Declarations from the standard library
- Declarations from external crates
- Declarations from other crates in this project
- Declarations from within this module

Furthermore, all use declarations are grouped together to enhance
readability. super::super is also replaced by an equivalent crate::
declaration.
2024-10-04 12:52:01 +08:00
5e2e77a500 [meta] Bump inkwell to v0.5 2024-09-13 11:11:14 +08:00
9c33c4209c [core] Fix type of ndarray.element_type
Should be the element type of the NDArray itself, not the pointer to its
type.
2024-08-30 22:47:38 +08:00
71c3a65a31 [core] codegen/stmt: Fix obtaining return type of sret functions 2024-08-29 19:15:30 +08:00
8c540d1033 [core] codegen/stmt: Add more casts for boolean types 2024-08-29 16:36:32 +08:00
0cc60a3d33 [core] codegen/expr: Fix missing cast to i1 2024-08-29 16:36:32 +08:00
a59c26aa99 [artiq] Fix RPC of ndarrays from host 2024-08-29 16:08:45 +08:00
9848795dcc core/irrt: add exceptions and debug utils 2024-08-27 22:55:22 +08:00
d3b4c60d7f core/irrt: comment build.rs & move irrt to nac3core/irrt 2024-08-27 22:55:22 +08:00
2c88924ff7 core: add support for simple polymorphism 2024-08-26 18:37:55 +08:00
2b2b2dbf8f [core] Fix resolution of exception names in raise short form
Previous implementation fails as `resolver.get_identifier_def` in ARTIQ
would return the exception __init__ function rather than the class.

We fix this by limiting the exception class resolution to only include
raise statements, and to force the exception name to always be treated
as a class.

Fixes #501.
2024-08-26 18:35:02 +08:00
d9f96dab33 [core] Add codegen_unreachable 2024-08-23 13:10:55 +08:00
4d80ba38b7 [core] codegen/expr: Implement comparison of tuples 2024-08-21 16:25:32 +08:00