Commit Graph

792 Commits

Author SHA1 Message Date
lyken 3bd344bd2b core/ndstrides: implement cmpop 2024-10-17 14:53:09 +08:00
lyken 92d2efcc6e core/ndstrides: implement unary op 2024-10-17 14:52:20 +08:00
lyken 39ae9bd630 core/ndstrides: implement binop 2024-10-17 14:52:18 +08:00
lyken 94e98c1bd9 core/ndstrides: add NDArrayOut, broadcast_map and map 2024-10-17 14:47:20 +08:00
lyken d12d62f078 core/ndstrides: implement subscript assignment
Overlapping is not handled. Currently it has undefined behavior.
2024-10-17 14:40:38 +08:00
lyken 5f31d6ec28 core/ndstrides: add more ScalarOrNDArray and NDArrayObject utils 2024-10-17 14:40:38 +08:00
lyken 020b776889 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-17 14:39:51 +08:00
lyken fc51bc63e2 core/ndstrides: implement broadcasting & np_broadcast_to() 2024-10-17 14:38:06 +08:00
lyken f8c0e2c4dd core/ndstrides: implement np_reshape() 2024-10-17 14:35:17 +08:00
lyken c156c7e46e core: categorize np_{transpose,reshape} as 'view functions' 2024-10-17 14:32:49 +08:00
lyken e33f74b331 core/ndstrides: implement np_size() 2024-10-17 14:31:55 +08:00
lyken c307a483bd 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-17 14:31:55 +08:00
lyken f57df4c6a7 core/ndstrides: implement ndarray.fill() and .copy() 2024-10-17 14:29:05 +08:00
lyken 532fccf1fb core/ndstrides: implement np_identity() and np_eye() 2024-10-17 14:29:05 +08:00
lyken de732ba68e 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-17 14:27:04 +08:00
lyken 2b6f1f7bc6 core/ndstrides: add NDArrayObject::atleast_nd 2024-10-17 14:27:03 +08:00
lyken 8bde4729ef core/ndstrides: add NDArrayObject::make_copy 2024-10-17 14:23:59 +08:00
lyken 0206c3989a 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
#486.
2024-10-17 13:56:35 +08:00
lyken a8928d35e7 core/ndstrides: implement len(ndarray) & refactor len() 2024-10-17 13:44:43 +08:00
lyken 76a1c80081 core/ndstrides: implement np_{zeros,ones,full,empty} 2024-10-17 13:44:43 +08:00
lyken 8d4c2fd9f2 core/model: add util::gen_for_model 2024-10-17 13:44:43 +08:00
lyken 1c8cb84fcf core/object: add ListObject and TupleObject
Needed for implementing other ndarray utils.
2024-10-17 13:44:43 +08:00
lyken 9d8358c0e7 core/ndstrides: implement ndarray iterator NDIter
A necessary utility to iterate through all elements in a possibly strided ndarray.
2024-10-17 13:44:43 +08:00
lyken 9d87975c01 core/ndstrides: introduce NDArray
NDArray with strides.
2024-10-17 13:44:43 +08:00
lyken b605006f58 core/toplevel/helper: add {extract,create}_ndims 2024-10-17 13:44:43 +08:00
lyken 5c18a32a28 core/object: introduce object
A small abstraction to simplify implementations.
2024-10-17 13:44:43 +08:00
lyken 0066c331d6 [core] introduce models 2024-10-17 13:44:43 +08:00
David Mak 56c845aac4 [standalone] Add support for registering globals without type decl 2024-10-07 20:44:06 +08:00
David Mak 65a12d9ab3 [core] Refactor registration of top-level variables 2024-10-07 17:05:48 +08:00
David Mak 9c6685fa8f [core] typecheck/function_check: Fix lookup of defined ids in scope 2024-10-07 16:51:37 +08:00
David Mak 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
David Mak 42a2f243b5 [core] typecheck: Disallow redeclaration of var shadowing global 2024-10-07 13:11:00 +08:00
David Mak 3ce2eddcdc [core] typecheck/type_inferencer: Infer whether variables are global 2024-10-07 13:10:46 +08:00
David Mak 51bf126a32 [core] typecheck/type_inferencer: Differentiate global symbols
Required for analyzing use of global symbols before global declaration.
2024-10-07 12:25:00 +08:00
David Mak 1a197c67f6 [core] toplevel/composer: Reduce lock scope while analyzing function 2024-10-05 15:53:20 +08:00
David Mak e60e8e837f [core] Add support for global statements 2024-10-04 13:24:27 +08:00
David Mak 9fdbe9695d [core] Add generator to SymbolResolver::get_symbol_value
Needed in a future commit.
2024-10-04 13:20:29 +08:00
David Mak 8065e73598 [core] toplevel/composer: Add type analysis for global variables 2024-10-04 13:20:29 +08:00
David Mak 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
David Mak 1407553a2f [core] Implement parsing of global variables
Globals are now parsed into symbol resolver and top level definitions.
2024-10-04 13:18:29 +08:00
David Mak c7697606e1 [core] Add TopLevelDef::Variable 2024-10-04 13:09:25 +08:00
David Mak a43b59539c [meta] Move variables declarations closer to where they are first used 2024-10-04 13:00:16 +08:00
David Mak 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
mwojcik f2c047ba57 artiq: support async rpcs
Co-authored-by: mwojcik <mw@m-labs.hk>
Co-committed-by: mwojcik <mw@m-labs.hk>
2024-09-13 12:12:13 +08:00
David Mak 5e2e77a500 [meta] Bump inkwell to v0.5 2024-09-13 11:11:14 +08:00
lyken 7f629f1579 core: fix comment in unify_call 2024-09-11 15:46:19 +08:00
lyken 5640a793e2 core: allow np_full to take tuple shapes 2024-09-11 15:46:19 +08:00
Sebastien Bourdeauducq 668ccb1c95 nac3core: expose inkwell and nac3parser 2024-09-06 11:06:26 +08:00
David Mak 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
David Mak 71c3a65a31 [core] codegen/stmt: Fix obtaining return type of sret functions 2024-08-29 19:15:30 +08:00