David Mak
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
David Mak
7d02f5833d
[core] codegen: Implement Tuple{Type,Value}
2025-01-03 13:58:47 +08:00
David Mak
822f9d33f8
[core] codegen: Refactor ListType to use derive(StructFields)
2025-01-03 13:58:47 +08:00
David Mak
805a9d23b3
[core] codegen: Add derive(Copy, Clone) to TypedArrayLikeAdapter
2025-01-03 13:58:46 +08:00
David Mak
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
David Mak
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
David Mak
3c0ce3031f
[core] codegen: Update raw_alloca to return PointerValue
...
Better match the expected behavior of alloca.
2024-12-30 16:51:34 +08:00
David Mak
d5e8df070a
[core] Minor improvements to IRRT and add missing documentation
2024-12-30 16:51:17 +08:00
David Mak
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
David Mak
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
David Mak
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
David Mak
0e5940c49d
[meta] Refactor itertools::{chain,enumerate,repeat_n} with std equiv
2024-12-30 14:13:48 +08:00
David Mak
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
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
David Mak
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
David Mak
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
David Mak
061747c67b
[core] codegen: Implement NDArrayValue::atleast_nd
...
Based on 9cfa2622: core/ndstrides: add NDArrayObject::atleast_nd.
2024-12-13 15:23:31 +08:00
David Mak
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
David Mak
438943ac6f
[core] codegen: Implement indexing for NDArray
...
Based on 8f9d2d82: 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-12-13 15:23:31 +08:00
fdfc80ca5f
[core] codegen: Implement Slice{Type,Value}, RustSlice
...
Based on 01c96396: core/irrt: add Slice and Range and part of
8f9d2d82: core/ndstrides: implement ndarray indexing.
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-12-13 15:23:31 +08:00
David Mak
8b3429d62a
[artiq] Reimplement get_obj_value for strided ndarray
...
Based on 7ef93472: artiq: reimplement get_obj_value to use ndarray with
strides
2024-12-13 15:23:31 +08:00
David Mak
ddd16738a6
[core] codegen: implement ndarray iterator NDIter
...
Based on 50f960ab: core/ndstrides: implement ndarray iterator NDIter
A necessary utility to iterate through all elements in a possibly
strided ndarray.
2024-12-13 15:23:31 +08:00
David Mak
e4bd376587
[core] codegen: Implement ContiguousNDArray
...
Fixes compatibility with linalg algorithms. matrix_power is missing due
to the need for indexing support.
2024-12-13 15:23:29 +08:00
David Mak
44498f22f6
[core] codegen: Implement NDArray functions from a0a1f35b
2024-12-13 15:22:11 +08:00
David Mak
110416d07a
[core] codegen/irrt: Add IRRT functions for strided-ndarray
2024-12-13 15:22:11 +08:00
David Mak
08a7d01a13
[core] Add itemsize and strides to NDArray struct
...
Temporarily disable linalg ndarray tests as they are not ported to work
with strided-ndarray.
2024-12-13 15:22:09 +08:00
David Mak
3cd36fddc3
[core] codegen/types: Add check_struct_type_matches_fields
...
Shorthand for checking if a type is representable by a StructFields
instance.
2024-12-12 11:40:44 +08:00
David Mak
56a7a9e03d
[core] codegen: Add helper functions for create+call functions
...
Replacement for various FnCall methods from legacy ndstrides
implementation.
2024-12-12 11:30:36 +08:00
David Mak
574ae40f97
[core] codegen: Add call_memcpy_generic_array
...
Replacement for Instance<Ptr>::copy_from from legacy ndstrides
implementation.
2024-12-12 11:30:36 +08:00
David Mak
aa293b6bea
[core] codegen: Add type_aligned_alloca
2024-12-12 11:30:35 +08:00
David Mak
eb4b881690
[core] Expose {types,values}::ndarray modules
...
Allows better encapsulation of members in these modules rather than
allowing them to leak into types/values mod.
2024-12-12 11:30:14 +08:00
David Mak
3d0a1d281c
[core] Expose irrt::ndarray
2024-12-10 12:49:49 +08:00
David Mak
ad67a99c8f
[core] codegen: Cleanup builtin_fns.rs
...
- Unpack tuples directly in function argument
- Replace Vec parameters with slices
- Replace unwrap-transform with map-unwrap
2024-12-10 12:49:49 +08:00
David Mak
8e2b50df21
[core] codegen/ndarray: Cleanup
...
- Remove redundant size param
- Add *_fields functions and docs
2024-12-09 13:01:08 +08:00
David Mak
06092ad29b
[core] Move alloca and map_value of ProxyType to implementations
...
These functions may not be invokable by the same set of parameters as
some classes has associated states.
2024-12-09 12:51:50 +08:00
David Mak
d62c6b95fd
[core] codegen/types: Rename StructField::set_from_value
2024-12-09 12:51:50 +08:00
David Mak
95e29d9997
[core] codegen: Move ndarray type/value as a separate module
2024-12-09 12:51:46 +08:00
David Mak
536ed2146c
[meta] Remove all mentions of build_int_cast
...
build_int_cast performs signed extension or truncation depending on the
source and target int lengths. This is usually not what we want - We
want zero-extension instead.
Replace all instances of build_int_cast with
build_int_z_extend_or_bit_cast to fix this issue.
2024-12-09 12:51:39 +08:00
babc081dbd
core/toplevel: update tests
2024-11-27 14:31:57 +08:00
5337dbe23b
core/toplevel: add python-like error messages for class definition
2024-11-27 14:31:57 +08:00
f862c01412
core/toplevel: refactor composer
2024-11-27 14:31:53 +08:00
David Mak
144f0922db
[core] coregen/types: Implement StructFields for NDArray
...
Also rename some fields to better align with their naming in numpy.
2024-11-21 14:27:00 +08:00
David Mak
c58ce9c3a9
[core] codegen/types: Implement NDArray in terms of i8*
...
Better aligns with the future implementation of ndstrides.
2024-11-21 14:27:00 +08:00
David Mak
f7e296da53
[core] irrt: Break IRRT into several impl files
...
Each IRRT file is now mapped to one Rust file.
2024-11-21 14:27:00 +08:00
David Mak
1a535db558
[core] codegen: Add dtype to NDArrayType
...
We won't have this once NDArray is refactored to strided impl.
2024-11-20 15:35:57 +08:00
David Mak
1ba2e287a6
[core] codegen: Add Self::llvm_type to all type abstractions
2024-11-20 15:35:57 +08:00
48e2148c0f
core/toplevel/helper: add {extract,create}_ndims
2024-11-20 15:35:57 +08:00
David Mak
88e57f7120
[core_derive] Initial implementation
2024-11-20 15:35:55 +08:00
David Mak
d7633c42bc
[core] codegen/types: Implement StructField{,s}
...
Loosely based on FieldTraversal by lyken.
2024-11-19 13:46:25 +08:00
David Mak
a4f53b6e6b
[core] codegen: Refactor ProxyType and ProxyValue
...
Accepts generator+context object for generic type checking. Also
implements more default trait impl for easier delegation.
2024-11-19 13:46:25 +08:00