-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Recursive Types #357
Comments
The length of an array is not part of the type (we have One solution is to add the length of the array to the type: // This is currently possible in a kernel
let array = Array::<T>::new(COMPTIME_VALUE);
// This is impossible as COMPTIME_VALUE is, in fact, a runtime value for rust.
let array = Array::<T, COMPTIME_VALUE)::new(); Also, it is unclear to me what are the implication in function signatures of #[cube]
fn do_something<T, const N: u32>(data: Array<T, N>) { } |
Also, what about Array<(Line<S>, Line<T>)> For example, in ArgMax I could want to use type Accumulator = Array<(Line<Float>, Line<u32>)>; Is it something we should support? |
Why
It is impossible right now to have an array of cmma matrix fragments, which is necessary to implement some optimizations. It's also quite constraining in general.
How
We should create the concept of
CubeTypeId
and add them to theCubeContext
. Right nowItem
is mostly used as type id, but this is wrong. In the context, we should have a map ofCubeTypeId => CubeTypeKind
, whereCubeTypeKind
is a new enum listing all possible types:The goal is the this will be easy to build up during expansion. But we would also need a recursive enum type for each compiler, so that it's easy to format.
With that, it would be easy to implement
Array<Matrix<C, 16, 16, 16, Accumulator>>>
, which is necessary for double buffering.Why a Type ID, vs directly in the Variable ?
Currently
Variable
implementsClone
&Copy
which makes it easier to work with. But it also means that we can't extend the enum to become resursive, sinceBox
doesn't implementCopy
. AlsoVariable
could probably be simplified in that case only having an id and a type id.The text was updated successfully, but these errors were encountered: