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

Removing grid lowering #2686

Merged
merged 1 commit into from
Apr 17, 2024
Merged

Removing grid lowering #2686

merged 1 commit into from
Apr 17, 2024

Conversation

apbose
Copy link
Collaborator

@apbose apbose commented Mar 11, 2024

This PR addresses the issue #2665

  1. Removing grid_sampler_2d from lowering ops
  2. Adding grid_sampler.default and grid_sampler_2d.default to the CONVERTER key registry
  3. Adding tests for grid_sampler.default and grid_sampler_2d.default tests
  4. Restructing the test
  5. Correcting the interpolation mode and padding mode in the tests

@apbose apbose requested a review from gs-olive March 11, 2024 23:52
@github-actions github-actions bot added component: tests Issues re: Tests component: lowering Issues re: The lowering / preprocessing passes component: conversion Issues re: Conversion stage component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Mar 11, 2024
@apbose
Copy link
Collaborator Author

apbose commented Mar 11, 2024

PR #2682 seems to adddress partially the above.


def forward(self, x):
grid = torch.randint(-1, 1, dim_shape, dtype=torch.float32)
return self.grid_sampler_op(x, grid, grid_sampler_aten_ops[op_name])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this need to be grid_sampler_aten_ops[op_name](x, grid)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@gs-olive yes it could be but then in that case it would be something like-

   def test_grid(self, _, op_name, input_shape, dim_shape, padding_mode, interpolation_mode, align_corners):
        class TestModule(nn.Module):
            def __init__(self):
                super().__init__()

            def forward(self, x):
                grid = torch.randint(-1, 1, dim_shape, dtype=torch.float32)
                return grid_sampler_aten_ops[op_name](x, grid, padding_mode, interpolation_mode, align_corners)

        inputs = [torch.randn(input_shape, dtype=torch.float32)]
        grid_model = TestModule()
        self.run_test(grid_model, inputs)

It would be code design choice to either encapsulate it in the lambda function in the parameters, or declare it in the above way. In my opinion both should be good.

You could let me know if you think otherwise.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see - this makes sense, thanks. In that case, it seems good to go - should just need a rebase to enable testing.

@apbose apbose merged commit 68d078e into main Apr 17, 2024
12 of 21 checks passed
peri044 pushed a commit that referenced this pull request Apr 19, 2024
laikhtewari pushed a commit that referenced this pull request May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: lowering Issues re: The lowering / preprocessing passes component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants