Commit Graph

1484 Commits

Author SHA1 Message Date
3c5e247195 [artiq] symbol_resolver: Use TargetData to get size of dtype
dtype.size_of() may not return a constant value.
2025-01-06 16:53:33 +08:00
4e21def1a0 [artiq] symbol_resolver: Add missing promotion for host compilation
Shape tuple is always in i32, so a zero-extension to i64 is
necessary when assigning the shape tuple into the shape field of the
ndarray.
2025-01-06 16:53:33 +08:00
2271b46b96 [core] codegen/values/ndarray: Fix Vec allocation 2025-01-06 16:53:33 +08:00
d9c180ed13 [artiq] symbol_resolver: Fix support for np.bool_ -> bool decay 2025-01-06 16:53:33 +08:00
8322d457c6 standalone/demo: numpy2 compatibility 2025-01-04 15:30:24 +08:00
e480081e4b update dependencies 2025-01-04 10:28:41 +08:00
12fddc3533 [core] codegen/ndarray: Make ndims non-optional
Now that everything is ported to use strided impl, dynamic-ndim ndarray
instances do not exist anymore.
2025-01-03 15:43:08 +08:00
3ac1083734 [core] codegen: Reimplement np_dot() for scalars and 1D
Based on 693b7f37: core/ndstrides: implement np_dot() for scalars and 1D
2025-01-03 15:43:08 +08:00
66b8a5e01d [core] codegen/ndarray: Reimplement matmul
Based on 73c2203b: core/ndstrides: implement general matmul
2025-01-03 15:43:06 +08:00
ebbadc2d74 [core] codegen: Reimplement ndarray cmpop
Based on 56cccce1: core/ndstrides: implement cmpop
2025-01-03 15:15:13 +08:00
a2f1b25fd8 [core] codegen: Reimplement ndarray unary op
Based on bb992704: core/ndstrides: implement unary op
2025-01-03 15:15:12 +08:00
59f19e29df [core] codegen: Reimplement ndarray binop
Based on 9e40c834: core/ndstrides: implement binop
2025-01-03 15:15:12 +08:00
6cbba8fdde [core] codegen: Reimplement builtin funcs to support strided ndarrays
Based on 7f3c4530: core/ndstrides: update builtin_fns to use ndarray
with strides
2025-01-03 15:15:12 +08:00
e6dab25a57 [core] codegen/ndarray: Add NDArrayOut, broadcast_map, map
Based on fbfc0b29: core/ndstrides: add NDArrayOut, broadcast_map and map
2025-01-03 15:15:11 +08:00
2dc5e79a23 [core] codegen/ndarray: Implement subscript assignment
Based on 5bed394e: core/ndstrides: implement subscript assignment

Overlapping is not handled. Currently it has undefined behavior.
2025-01-03 15:15:11 +08:00
dcde1d9c87 [core] codegen/values/ndarray: Add more ScalarOrNDArray utils
Based on f731e604: core/ndstrides: add more ScalarOrNDArray and
NDArrayObject utils
2025-01-03 15:15:10 +08:00
7375983e0c [core] codegen/ndarray: Implement np_transpose without axes argument
Based on 052b67c8: core/ndstrides: implement np_transpose() (no axes
argument)

The IRRT implementation knows how to handle axes. But the argument is
not in NAC3 yet.
2025-01-03 15:15:08 +08:00
43e440d2fd [core] codegen/ndarray: Reimplement broadcasting
Based on 9359ed96: core/ndstrides: implement broadcasting &
np_broadcast_to()
2025-01-03 15:14:59 +08:00
8d975b5ff3 [core] codegen/ndarray: Implement np_reshape
Based on 926e7e93: core/ndstrides: implement np_reshape()
2025-01-03 14:56:16 +08:00
aae41eef6a [core] toplevel: Add view functions category
Based on 9e0f636d: core: categorize np_{transpose,reshape} as 'view
functions'
2025-01-03 14:47:59 +08:00
132ba1942f [core] toplevel: Implement np_size
Based on 2c1030d1: core/ndstrides: implement np_size()
2025-01-03 14:16:29 +08:00
12358c57b1 [core] codegen/ndarray: Implement np_{shape,strides}
Based on 40c24486: 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.
2025-01-03 13:58:47 +08:00
9ffa2d6552 [core] codegen/ndarray: Reimplement np_{copy,fill}
Based on 18db85fa: core/ndstrides: implement ndarray.fill() and .copy()
2025-01-03 13:58:47 +08:00
acb437919d [core] codegen/ndarray: Reimplement np_{eye,identity}
Based on fa047d50: core/ndstrides: implement np_identity() and np_eye()
2025-01-03 13:58:47 +08:00
fadadd7505 [core] codegen/ndarray: Reimplement np_array()
Based on 8f0084ac: 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)`.
2025-01-03 13:58:47 +08:00
26f1428739 [core] codegen: Refactor len()
Based on 54a842a9: core/ndstrides: implement len(ndarray) & refactor
len()
2025-01-03 13:58:47 +08:00
5880f964bb [core] codegen/ndarray: Reimplement np_{zeros,ones,full,empty}
Based on 792374fa: core/ndstrides: implement np_{zeros,ones,full,empty}.
2025-01-03 13:58:47 +08:00
7d02f5833d [core] codegen: Implement Tuple{Type,Value} 2025-01-03 13:58:47 +08:00
822f9d33f8 [core] codegen: Refactor ListType to use derive(StructFields) 2025-01-03 13:58:47 +08:00
805a9d23b3 [core] codegen: Add derive(Copy, Clone) to TypedArrayLikeAdapter 2025-01-03 13:58:46 +08:00
1ffe2fcc7f [core] irrt: Minor reformat 2025-01-03 13:26:51 +08:00
2f0847d77b [core] codegen/types: Refactor ProxyType
- Add alloca_type() function to obtain the type that should be passed
into a `build_alloca` call
- Provide default implementations for raw_alloca and array_alloca
- Add raw_alloca_var and array_alloca_var to distinguish alloca
instructions placed at the front of the function vs at the current
builder location
2024-12-30 17:00:17 +08:00
dc9efa9e8c [core] codegen/ndarray: Use IRRT for size() and indexing operations
Also refactor some usages of call_ndarray_calc_size with ndarray.size().
2024-12-30 16:58:33 +08:00
3c0ce3031f [core] codegen: Update raw_alloca to return PointerValue
Better match the expected behavior of alloca.
2024-12-30 16:51:34 +08:00
d5e8df070a [core] Minor improvements to IRRT and add missing documentation 2024-12-30 16:51:17 +08:00
dc413dfa43 [core] codegen: Refactor TypedArrayLikeAdapter to use fn
Allows for greater flexibility when TypedArrayLikeAdapter is used with
custom value types.
2024-12-30 16:50:22 +08:00
19122e2905 [core] codegen: Rename classes/functions for consistency
- ContiguousNDArrayFields -> ContiguousNDArrayStructFields
- ndarray/nditer: Add _field suffix to field accessors
2024-12-30 16:50:18 +08:00
318371a509 [core] irrt: Minor cleanup 2024-12-30 14:13:48 +08:00
35e3042435 [core] Refactor/Remove redundant and unused constructs
- Use ProxyValue.name where necessary
- Remove NDArrayValue::ptr_to_{shape,strides}
- Remove functions made obsolete by ndstrides
- Remove use statement for ndarray::views as it only contain an impl
block.
- Remove class_names field in Resolvers of test sources
2024-12-30 14:13:48 +08:00
0e5940c49d [meta] Refactor itertools::{chain,enumerate,repeat_n} with std equiv 2024-12-30 14:13:48 +08:00
fbf0053c24 [core] irrt/string: Minor cleanup
- Refactor __nac3_str_eq to always return bool
- Use `get_usize_dependent_function_name` to get IRRT func name
2024-12-30 14:04:42 +08:00
456aefa6ee clean up duplicate include 2024-12-30 13:03:31 +08:00
ram
49a7469b4a use memcmp for string comparison
Co-authored-by: ram <RAMTEJ001@e.ntu.edu.sg>
Co-committed-by: ram <RAMTEJ001@e.ntu.edu.sg>
2024-12-30 13:02:09 +08:00
1531b6cc98 cargo: update dependencies 2024-12-13 19:42:01 +08:00
9bbc40bbfa flake: update dependencies 2024-12-13 19:41:52 +08:00
790e56d106 msys2: update 2024-12-13 19:39:39 +08:00
a00eb7969e [core] codegen: Implement matrix_power
Last of the functions that need to be ported over to strided-ndarray.
2024-12-13 15:23:31 +08:00
27a6f47330 [core] codegen: Implement construction of unsized ndarrays
Partially based on f731e604: core/ndstrides: add more ScalarOrNDArray
and NDArrayObject utils.
2024-12-13 15:23:31 +08:00
061747c67b [core] codegen: Implement NDArrayValue::atleast_nd
Based on 9cfa2622: core/ndstrides: add NDArrayObject::atleast_nd.
2024-12-13 15:23:31 +08:00
dc91d9e35a [core] codegen: Implement ScalarOrNDArray and use it in indexing
Based on 8f9d2d82: core/ndstrides: implement ndarray indexing.
2024-12-13 15:23:31 +08:00