Commit Graph

793 Commits

Author SHA1 Message Date
lyken 8312ec2278
core/ndstrides: implement 1D np_dot() 2024-08-20 23:32:14 +08:00
lyken 660928bfba
core/ndstrides: implement general ndarray matmul 2024-08-20 23:32:11 +08:00
lyken ed18c3801b
core/ndstrides: update binop to use ndarray with strides 2024-08-20 23:32:09 +08:00
lyken 9bca7838a4
core/ndstrides: add ScalarOrNDArray::split_object 2024-08-20 23:32:07 +08:00
lyken 11824e9420
core/ndstrides: add ScalarOrNDArray::get_dtype 2024-08-20 23:31:53 +08:00
lyken 0c6ba9fd6b
core/ndstrides: add NDArrayOut, broadcast_map and map 2024-08-20 23:31:49 +08:00
lyken 9173e52435
core/ndstrides: add ScalarOrNDArray::to_ndarray and NDArrayObject::make_unsized 2024-08-20 23:31:48 +08:00
lyken 0ccae59b19
core/ndstrides: add TryFrom impls for ScalarOrNDArray 2024-08-20 23:31:34 +08:00
lyken 6fe17c71e3
core/ndstrides: implement np_transpose() (no axes argument) 2024-08-20 23:31:29 +08:00
lyken 22d9aac930
core/ndstrides: implement np_reshape() 2024-08-20 23:31:28 +08:00
lyken 578b53d8ce
core: categorize np_{transpose,reshape} as 'view functions' 2024-08-20 23:31:26 +08:00
lyken b216c82875
core/ndstrides: implement np_size() 2024-08-20 23:31:23 +08:00
lyken dae0eff771
core/ndstrides: implement np_shape() and np_strides()
These functions are not important, but they are handy for debugging +
implementing them takes little effort.

NOTE: `np.strides()` is not an actual NumPy function. You can only(?)
access them thru `ndarray.strides`.
2024-08-20 23:31:04 +08:00
lyken 0d1380b4d4
core/ndstrides: implement ndarray.fill() and .copy() 2024-08-20 23:30:06 +08:00
lyken d94feb1424
core/ndstrides: implement np_identity() and np_eye() 2024-08-20 23:29:53 +08:00
lyken 632f736fac
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]]`. Previously it was a todo of
`np_array()`.
2024-08-20 23:29:45 +08:00
lyken f44b361ec1
core/ndstrides: add NDArrayObject::atleast_nd 2024-08-20 23:29:44 +08:00
lyken ff48f9549a
core/ndstrides: add NDArrayObject::make_copy 2024-08-20 23:29:43 +08:00
lyken 171283c0bb
core/irrt: add List
Needed for implementing np_array()
2024-08-20 23:29:29 +08:00
lyken aca2305bfb
core/codegen: implement genereal ndarray indexing
`...`, `none` are now also supported.
2024-08-20 23:29:24 +08:00
lyken 4660d553de
core/irrt: rename NDIndex to NDIndexInt
The name `NDIndex` is used in later commits.
2024-08-20 23:29:23 +08:00
lyken c20736307d
core/irrt: add Slice and ResolvedSlice
Needed for implementing general ndarray indexing
2024-08-20 23:29:22 +08:00
lyken 2fe0611733
core/codegen: refactor call_len() & update to ndarray with strides 2024-08-20 23:29:08 +08:00
lyken e7846d9cd9
core/ndstrides: implement ndarray np_{zeros,ones,full,empty} 2024-08-20 23:29:07 +08:00
lyken c6c07e074a
core/object: add is_instance for ndarray, tuple and list 2024-08-20 23:28:54 +08:00
lyken de9f4775d5
core/model: add util::gen_for_model 2024-08-20 23:28:52 +08:00
lyken 7ad7918f11
core/object: add ListObject and TupleObject
Needed for implementing other ndarray utils.
2024-08-20 23:28:43 +08:00
lyken 5113c12b8b
core/ndstrides: add ndarray iterator 2024-08-20 17:03:51 +08:00
lyken 51740c6c90
core/ndstrides: add basic ndarray utilities 2024-08-20 17:03:51 +08:00
lyken f090b3b4d2
core/ndstrides: define ndarray with strides 2024-08-20 17:03:51 +08:00
lyken 9d8cc0c59d
core/toplevel/helper: add {extract,create}_ndims 2024-08-20 17:03:51 +08:00
lyken 5f4486bbbb
core/object: introduce object
Small abstraction to simplify implementations.
2024-08-20 17:03:50 +08:00
lyken d98919fdf9
core/model: introduce models 2024-08-20 15:35:47 +08:00
lyken 82c4908305
core/fix: add missing lifetime in gen_for* 2024-08-20 15:35:47 +08:00
lyken 7436ce8ba8
core/fix: stringify type in expected concrete type error 2024-08-20 15:35:47 +08:00
lyken eb1dee81d0
core/irrt/exceptions: add debug utils with exceptions 2024-08-20 15:35:47 +08:00
lyken 61ecbb4e47
core/irrt/exceptions: allow irrt to raise exceptions 2024-08-20 15:35:47 +08:00
lyken dcd9010dd1
core/irrt: split irrt.cpp into headers 2024-08-20 15:35:47 +08:00
lyken f742b303ab
core/irrt: build.rs capture IR defined constants 2024-08-20 15:35:47 +08:00
lyken bc595d3552
core/irrt: build.rs capture IR defined types 2024-08-20 15:35:47 +08:00
lyken 290e6b97d2
core/irrt: reformat 2024-08-20 15:35:47 +08:00
lyken 9b3790631d
core/irrt: comment build.rs & move irrt to its own dir
To prepare for future IRRT implementations, and to also make cargo
only have to watch a single directory.
2024-08-20 15:35:47 +08:00
David Mak 9e0601837a core: Add compile-time feature to disable escape analysis 2024-08-14 09:29:48 +08:00
lyken 432c81a500
core: update insta after #489 2024-08-13 15:30:34 +08:00
David Mak 8fd7216243 [core] toplevel/composer: Add lateinit_builtins
This is required for the new core_log and rtio_log functions, which take
a generic type as its parameter. However, in ARTIQ builtins are
initialized using one unifier and then actually used by another unifier.

lateinit_builtins workaround this issue by deferring the initialization
of functions requiring type variables until the actual unifier is ready.
2024-08-13 15:19:03 +08:00
David Mak a0614bad83 [core] codegen/expr: Make gen_string return `StructValue`
So that it is clear that the value itself is returned rather than a
pointer to the struct or its data.
2024-08-13 15:19:03 +08:00
David Mak 5539d144ed [core] Add `CodeGenContext::build_in_bounds_gep_and_load`
For safer accesses to `gep`-able values and faster fails.
2024-08-13 15:19:03 +08:00
lyken 973dc5041a core/typecheck: Support tuple arg type in len() 2024-08-13 15:02:59 +08:00
David Mak 12c4e1cf48 core/toplevel/builtins: Add support for len() on tuples 2024-08-13 15:02:59 +08:00
David Mak 9b988647ed core/toplevel/builtins: Extract len() into builtin function 2024-08-13 15:02:59 +08:00