-
Notifications
You must be signed in to change notification settings - Fork 0
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
Slicing #19
Slicing #19
Conversation
f82c5cb
to
364614b
Compare
TensorLib/Slice.lean
Outdated
> Defaults for i:j:k | ||
> | ||
> Assume n is the number of elements in the dimension being sliced. | ||
> Then, if i is not given it defaults to 0 for step > 0 and n - 1 for step < 0 . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are using step
and k
interchangeably
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, got my verbatim quote messed up. Fixed.
TensorLib/Slice.lean
Outdated
def build (start stop step : Option Int) : Err Slice := | ||
match H : step with | ||
| .none => | ||
let stepNz : step ≠ some 0 := by aesop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by aesop
seems pretty heavy, is this just trivial
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, close. Removed aesop here. Maybe we should come up with some conventions around automation should be.
TensorLib/Slice.lean
Outdated
|
||
def all : Slice := | ||
let stepNz : Option.none ≠ .some (0:Int) := by trivial | ||
Slice.mk .none .none .none stepNz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, cool.
TensorLib/Slice.lean
Outdated
iter := iter' | ||
match <- f n res with | ||
| .yield k | ||
| .done k => res := k |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as other review. Does this properly support break
and return
in the for loops?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the same way, added tests.
364614b
to
239e471
Compare
Implements Python's slice operator, commonly used in NumPy indexing.