Skip to content

Functions #364

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

Closed
wants to merge 7 commits into from
Closed

Functions #364

wants to merge 7 commits into from

Conversation

inducer
Copy link
Owner

@inducer inducer commented Oct 14, 2022

cc @kaushikcfd

This is a draft because:

@kaushikcfd kaushikcfd force-pushed the functions branch 3 times, most recently from 7846ab7 to 3b226ae Compare October 18, 2022 06:06
@kaushikcfd kaushikcfd force-pushed the functions branch 2 times, most recently from e060c67 to edb1b19 Compare October 19, 2022 23:10
@kaushikcfd kaushikcfd force-pushed the functions branch 5 times, most recently from 36ca60a to 7378490 Compare November 5, 2022 06:32
@kaushikcfd kaushikcfd mentioned this pull request Nov 5, 2022
@kaushikcfd kaushikcfd force-pushed the functions branch 12 times, most recently from 66e173d to 88bed5c Compare November 9, 2022 06:37
@kaushikcfd
Copy link
Collaborator

This is ready! And can be reviewed after we merge #387.

@kaushikcfd kaushikcfd marked this pull request as ready for review November 9, 2022 21:14
@kaushikcfd kaushikcfd force-pushed the functions branch 6 times, most recently from 6a81131 to 4f2deaa Compare March 8, 2023 20:47
@kaushikcfd
Copy link
Collaborator

@inducer: This is ready to land, IMO.

@kaushikcfd kaushikcfd force-pushed the functions branch 2 times, most recently from c39d7d3 to a0ae9c7 Compare April 10, 2023 20:14
Copy link
Owner Author

@inducer inducer left a comment

Choose a reason for hiding this comment

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

I'm still missing transform.calls, but I figured I would submit this to see how you feel about these comments.

Copy link
Owner Author

@inducer inducer left a comment

Choose a reason for hiding this comment

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

Here are a few more review comments for transform.calls, which I've started on.

But it occurred to me that this is sufficiently unwieldy that it's probably best to split this into "everything else" and the transforms for merge.

def combine(self, *args: FrozenSet[CallSiteLocation]
) -> FrozenSet[CallSiteLocation]:
from functools import reduce
return reduce(lambda a, b: a | b, args, frozenset())
Copy link
Owner Author

Choose a reason for hiding this comment

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

Suggested change
return reduce(lambda a, b: a | b, args, frozenset())
return reduce(operator.or_, frozenset())

Comment on lines +205 to +207
:class:`CallSiteLocation`\ s being built. Must be altered (by creating
a new instance of the mapper) before entering the function body of a
new :class:`~pytato.function.Call`.
Copy link
Owner Author

Choose a reason for hiding this comment

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

Suggested change
:class:`CallSiteLocation`\ s being built. Must be altered (by creating
a new instance of the mapper) before entering the function body of a
new :class:`~pytato.function.Call`.
:class:`CallSiteLocation`\ s being built.

(Only of interest to implementers of subclasses, quite apparent from code. Plus I disagree with the phrasing "altered".)

Comment on lines +261 to +263
self.replacement_map, # type: ignore[attr-defined]
self.current_stack + (expr,), # type: ignore[attr-defined]
self.stack_to_replace_on, # type: ignore[attr-defined]
Copy link
Owner Author

Choose a reason for hiding this comment

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

Why not just declare the types in the class body? (That is, IIUC this correctly.)

stack_to_replace_on: Tuple[Call, ...]) -> None:
self.replacement_map = replacement_map
self.current_stack = current_stack
self.stack_to_replace_on = stack_to_replace_on
Copy link
Owner Author

Choose a reason for hiding this comment

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

It looks like this is done one stack at a time. Is that the most efficient approach? (vs. batching)

return super().map_named_call_result(expr)


def _have_same_axis_length(arrays: Collection[Array],
Copy link
Owner Author

Choose a reason for hiding this comment

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

What (if not an error) should this return if the collection is empty?

for other_ary in arrays)


def _have_same_axis_length_except(arrays: Collection[Array],
Copy link
Owner Author

Choose a reason for hiding this comment

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

What (if not an error) should this return if the collection is empty?

@inducer
Copy link
Owner Author

inducer commented May 17, 2023

It looks like 12f7524 ("Add regressions pt.inline_calls") contains a bit more than the commit message lets on.

This was referenced May 18, 2023
@inducer
Copy link
Owner Author

inducer commented May 18, 2023

Superseded by #436 and #437. I've untangled the unrelated aspects of 12f7524 in the rebase that led to those.

@inducer inducer closed this May 18, 2023
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