1
0
forked from M-Labs/nac3
Commit Graph

812 Commits

Author SHA1 Message Date
d222236492
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-08-30 14:40:15 +08:00
13715dbda9
core/irrt: add List
Needed for implementing np_array()
2024-08-30 14:20:19 +08:00
7910de10a1
core/ndstrides: add NDArrayObject::atleast_nd 2024-08-30 14:18:34 +08:00
6edc3f895b
core/ndstrides: add NDArrayObject::make_copy 2024-08-30 14:18:17 +08:00
a40cdde8d2
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-08-30 14:12:54 +08:00
853fa39537
core/irrt: rename NDIndex to NDIndexInt
Unfortunately the name `NDIndex` is used in later commits. Renaming this
typedef to `NDIndexInt` to avoid amending. `NDIndexInt` will be removed
anyway when ndarray strides is completed.
2024-08-30 14:00:19 +08:00
b6a1880226
core/irrt: add Slice and Range
Needed for implementing general ndarray indexing.

Currently IRRT slice and range have nothing to do with NAC3's slice
and range. The IRRT slice and range are currently there to implement
ndarray specific features. However, in the future their definitions may
be used to replace that of NAC3's. (NAC3's range is a [i32 x 3], IRRT's
range is a proper struct. NAC3 does not have a slice struct).
2024-08-30 13:57:10 +08:00
d1c75c7444
core/ndstrides: implement len(ndarray) & refactor len() 2024-08-30 13:45:25 +08:00
58c5bc56b9
core/ndstrides: implement np_{zeros,ones,full,empty} 2024-08-30 13:44:12 +08:00
ddc0e44c61
core/model: add util::gen_for_model 2024-08-30 13:42:39 +08:00
549536f72c
core/object: add ListObject and TupleObject
Needed for implementing other ndarray utils.
2024-08-30 13:41:31 +08:00
40c42b571a
core/ndstrides: implement ndarray iterator NDIter
A necessary utility to iterate through all elements in a possibly strided ndarray.
2024-08-30 13:39:10 +08:00
92e7103ec7
core/ndstrides: introduce NDArray
NDArray with strides.
2024-08-30 13:24:45 +08:00
9bc5e96dba
core/irrt: fix exception.hpp C++ castings 2024-08-30 13:15:07 +08:00
78639b1030
core/toplevel/helper: add {extract,create}_ndims 2024-08-30 13:05:16 +08:00
9723c17e24
core/object: introduce object
A small abstraction to simplify implementations.
2024-08-30 13:04:54 +08:00
d1c7a8ee50
StructKind::{traverse -> iter}_fields 2024-08-30 12:51:17 +08:00
e0524c19eb
Newline "Otherwise, it will be caught..." 2024-08-30 12:51:17 +08:00
32822f9052
gep_index must be u32 2024-08-30 12:51:17 +08:00
6283036815
FieldTraversal::{Out -> Output} 2024-08-30 12:51:17 +08:00
f167f5f215
Ptr::copy_from to use SizeT 2024-08-30 12:51:17 +08:00
baf8ee2b3d
Ptr::offset_const offset i64, can be negative 2024-08-30 12:51:17 +08:00
d68760447f
Int::const_int to have sign_extend 2024-08-30 12:51:17 +08:00
fdd194ee2a
FnCall::{begin -> builder} 2024-08-30 12:51:17 +08:00
5fca81c68e
CallFunction -> FnCall 2024-08-30 12:51:17 +08:00
0562e9a385
Instance add newline 2024-08-30 12:51:17 +08:00
36af473816
unsafe Model::believe_value 2024-08-30 12:51:17 +08:00
7c7e1b3ab8
Model::{sizeof -> size_of} 2024-08-30 12:51:17 +08:00
dbcfc9538a
ArrayLen::{get_length -> length} 2024-08-30 12:51:17 +08:00
5c4ba09e2f
LenKind -> ArrayLen 2024-08-30 12:51:17 +08:00
eb34b99ee9
core/model: renaming and add notes on upgrading Ptr to LLVM 15 2024-08-30 12:51:17 +08:00
d397b9ceaa
core/model: introduce models 2024-08-30 12:51:17 +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
15ac00708a [core] Use quoted include paths instead of angled brackets
This is preferred for user-defined headers.
2024-08-28 16:37:03 +08:00
22c4d25802 core/typecheck: add missing typecheck in matmul 2024-08-27 22:59:39 +08:00
9848795dcc core/irrt: add exceptions and debug utils 2024-08-27 22:55:22 +08:00
58222feed4 core/irrt: split into headers 2024-08-27 22:55:22 +08:00
518f21d174 core/irrt: build.rs capture IR defined constants 2024-08-27 22:55:22 +08:00
e8e49684bf core/irrt: build.rs capture IR defined types 2024-08-27 22:55:22 +08:00
b2900b4883 core/irrt: use +std=c++20 to compile
To explicitly set the C++ variant and avoid inconsistencies.
2024-08-27 22:55:22 +08:00
c6dade1394 core/irrt: reformat 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
5b2b6db7ed core: improve error messages 2024-08-26 18:37:55 +08:00
2c88924ff7 core: add support for simple polymorphism 2024-08-26 18:37:55 +08:00
a744b139ba core: allow Call and AnnAssign in init block 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