Commit Graph

21 Commits

Author SHA1 Message Date
a525592941 [core] codegen/ndarray: Reimplement matmul
Based on 73c2203b: core/ndstrides: implement general matmul
2024-12-24 15:39:40 +08:00
7da45a4fbd [core] codegen: Reimplement ndarray cmpop
Based on 56cccce1: core/ndstrides: implement cmpop
2024-12-24 15:39:34 +08:00
d1bf5085a6 [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.
2024-12-24 15:32:58 +08:00
32e1d55de9 [core] codegen/ndarray: Reimplement broadcasting
Based on 9359ed96: core/ndstrides: implement broadcasting &
np_broadcast_to()
2024-12-24 15:32:32 +08:00
936749ae5f [core] codegen/ndarray: Implement np_reshape
Based on 926e7e93: core/ndstrides: implement np_reshape()
2024-12-24 15:21:25 +08:00
1eb462a5c2 [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)`.
2024-12-24 15:19:00 +08:00
90071be0a7 [core] codegen/ndarray: Use IRRT for size() and indexing operations
Also refactor some usages of call_ndarray_calc_size with ndarray.size().
2024-12-24 15:10:01 +08:00
b3d7001561 [core] irrt: Minor cleanup 2024-12-24 14:54:29 +08:00
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
#486.
2024-12-13 15:23:31 +08:00
678e56c95d [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-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
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
110416d07a [core] codegen/irrt: Add IRRT functions for strided-ndarray 2024-12-13 15:22:11 +08:00
b58c99369e [core] irrt: Update some IRRT implementation
- Change CSlice to use `void*` for better pointer compatibility
- Only include impl *.hpp files in irrt.cpp
- Refactor typedef to using declaration
- Add missing ``// namespace`
2024-11-21 14:26:58 +08:00
f95f979ad3 core/irrt: fix exception.hpp C++ castings 2024-11-20 15:35:57 +08:00
bd06155f34 irrt: compatibility with pre-C23 compilers 2024-09-05 18:54:55 +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
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
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