Skip to content
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

High level support and testsing for span-to-fixed-sized array. #5583

Merged
merged 1 commit into from
May 21, 2024

Conversation

orizi
Copy link
Collaborator

@orizi orizi commented May 19, 2024

Copy link
Collaborator

@TomerStarkware TomerStarkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on @ilyalesokhin-starkware)

@orizi orizi force-pushed the pr/orizi/multi-pop/d131660d branch from 6561150 to cc736d1 Compare May 19, 2024 08:03
@orizi orizi force-pushed the pr/orizi/multi-pop/78f53cb7 branch from ae9297d to 7c83f01 Compare May 19, 2024 08:03
@ilyalesokhin-starkware
Copy link
Contributor

corelib/src/array.cairo line 274 at r1 (raw file):

}

impl SpanTryIntoEmptyFixedSizedArray<T, +Drop<T>> of TryInto<Span<T>, Box<@[T; 0]>> {

why is this needed?

Code quote:

SpanTryIntoEmptyFixedSizedArray<T, +Drop<T>> of TryInto<Span<T>, Box<@[T; 0]>>

Copy link
Collaborator Author

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @ilyalesokhin-starkware)


corelib/src/array.cairo line 274 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

why is this needed?

this just makes try-into for empty sized arrays work.

@ilyalesokhin-starkware
Copy link
Contributor

corelib/src/array.cairo line 262 at r1 (raw file):

/// The additional `+Copy<@T>` arg is to prevent later stages from propagating the `S` type Sierra
/// level, where it is deduced by the `T` type.
extern fn tuple_from_span<T, +Copy<@T>, S>(span: @Array<S>) -> Option<Box<@T>> nopanic;

why can't we use the following signature?

Suggestion:

extern fn tuple_from_span<T, SIZE: u32>(span: @Array<T>) -> Option<Box<[T, SIZE]>> nopanic;

Copy link
Collaborator Author

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware)


corelib/src/array.cairo line 262 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

why can't we use the following signature?

no - look at the above comment.
will change it to be inner type based soon.

but currently like span_from_tuple

@ilyalesokhin-starkware
Copy link
Contributor

corelib/src/array.cairo line 262 at r1 (raw file):

Previously, orizi wrote…

no - look at the above comment.
will change it to be inner type based soon.

but currently like span_from_tuple

I read the comment and didn't understand it.

Copy link
Collaborator Author

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware)


corelib/src/array.cairo line 262 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

I read the comment and didn't understand it.

the only type in the generics of the libfunc is T - the following args must not be passed to the libfunc.
since i want it to be exactly the same as span_from_tuple i don't want to limit it to only returning the fixed_size_array in the libfunc - so we are only dependent on the tuple like struct T, and the size is not part of the signature.

@ilyalesokhin-starkware
Copy link
Contributor

corelib/src/array.cairo line 262 at r1 (raw file):

Previously, orizi wrote…

the only type in the generics of the libfunc is T - the following args must not be passed to the libfunc.
since i want it to be exactly the same as span_from_tuple i don't want to limit it to only returning the fixed_size_array in the libfunc - so we are only dependent on the tuple like struct T, and the size is not part of the signature.

"the following args must not be passed to the libfunc."
what does that mean?

Copy link
Collaborator Author

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware)


corelib/src/array.cairo line 262 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

"the following args must not be passed to the libfunc."
what does that mean?

it isn't part of the expected generic args by sierra.

@ilyalesokhin-starkware
Copy link
Contributor

corelib/src/array.cairo line 262 at r1 (raw file):

Previously, orizi wrote…

it isn't part of the expected generic args by sierra.

how does +Copy<@t> prevent propagating the S type to sierra

Copy link
Collaborator Author

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware and @t)


corelib/src/array.cairo line 262 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

how does +Copy<@t> prevent propagating the S type to sierra

impl args and everything following are not passed to sierra.

@ilyalesokhin-starkware
Copy link
Contributor

corelib/src/array.cairo line 262 at r1 (raw file):

Previously, orizi wrote…

impl args and everything following are not passed to sierra.

Why did you decide on using +Copy
instead of +IgnoreFollowingArgs?

@ilyalesokhin-starkware
Copy link
Contributor

corelib/src/array.cairo line 262 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

Why did you decide on using +Copy
instead of +IgnoreFollowingArgs?

maybe use
S_
?

Copy link
Collaborator Author

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware and @t)


corelib/src/array.cairo line 262 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

maybe use
S_
?

it is already used - and will soon be removed - rather not add boilerplate for this PR.

@ilyalesokhin-starkware
Copy link
Contributor

corelib/src/test/array_test.cairo line 149 at r3 (raw file):

}

fn debox<T, const SIZE: usize>(value: Option<@Box<[T; SIZE]>>) -> Option<@[T; SIZE]> {

what is debox?
can you document it?

Code quote:

debox

Copy link
Collaborator Author

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on @ilyalesokhin-starkware and @t)


corelib/src/test/array_test.cairo line 149 at r3 (raw file):

Previously, ilyalesokhin-starkware wrote…

what is debox?
can you document it?

Done.

@orizi orizi force-pushed the pr/orizi/multi-pop/78f53cb7 branch from 1f25cd7 to cb14a09 Compare May 20, 2024 09:10
@orizi orizi force-pushed the pr/orizi/multi-pop/d131660d branch from 550ddf4 to 7416a32 Compare May 20, 2024 09:10
@ilyalesokhin-starkware
Copy link
Contributor

corelib/src/test/array_test.cairo line 149 at r3 (raw file):

Previously, orizi wrote…

Done.

Why do you need to wrap it in a snapshot?

Copy link
Collaborator Author

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on @ilyalesokhin-starkware and @t)


corelib/src/test/array_test.cairo line 149 at r3 (raw file):

Previously, ilyalesokhin-starkware wrote…

Why do you need to wrap it in a snapshot?

The input already had a snapshot, leaving the snapshot here remove the need to require the data to have Copy

Copy link
Contributor

@ilyalesokhin-starkware ilyalesokhin-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 3 files at r1, 1 of 2 files at r2, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @orizi)

@orizi orizi force-pushed the pr/orizi/multi-pop/d131660d branch from 7416a32 to 3f2bbd7 Compare May 21, 2024 06:22
@orizi orizi changed the base branch from pr/orizi/multi-pop/78f53cb7 to main May 21, 2024 06:22
@orizi orizi enabled auto-merge May 21, 2024 06:23
@orizi orizi added this pull request to the merge queue May 21, 2024
Merged via the queue into main with commit bde5f45 May 21, 2024
84 of 85 checks passed
@orizi orizi deleted the pr/orizi/multi-pop/d131660d branch June 10, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants