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

feat: Add support for dynamic zeros_like and ones_like #1847

Merged

Conversation

mfeliz-cruise
Copy link
Contributor

Description

Adds support for a variety of tensor creation ops including dynamic shape support for ones_like and zeros_like.

Ops supported:
aten::new_zeros
aten::new_ones
aten::zeros_like
aten::ones_like
aten::fill_

Fixes # (issue)

Type of change

Please delete options that are not relevant and/or add your own.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@github-actions github-actions bot added component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: evaluators Issues re: Specific op evaluators component: tests Issues re: Tests labels Apr 21, 2023
@github-actions github-actions bot requested a review from bowang007 April 21, 2023 00:04
@@ -124,6 +125,77 @@ DEFINE_TWO_INPUT_SIMPLE_EVALUATOR(
int64_t,
{"aten::__round_to_zero_floordiv(int a, int b) -> (int)"});

std::pair<std::vector<int64_t>, torch::TensorOptions> newTensorImplementation(const torch::jit::Node* n, kwargs& args) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should probably put these helpers in the utils file.

auto tensor = tensor_var.unwrapToTensor();
tensor_dims = tensor.sizes().vec();
}
if (ctx->input_is_dynamic) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This condition is too broad and results in additional bugs being injected. In the other dynamic shape PRs we also use the opt in shape tensor setting to limit the scope which should be good enough for now but really this should only run when the input is itself a ShapeTensor.

Copy link
Collaborator

@narendasan narendasan left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the comments, LGTM me now, pending CI

@mfeliz-cruise
Copy link
Contributor Author

@narendasan It looks like the CI issue is not specific to this PR. Any action needed on my side? ERROR: Could not find a version that satisfies the requirement torch==2.1.0.dev20230314+cu117

@narendasan
Copy link
Collaborator

You might need to rebase, the nightly version might be too old for this base branch

@mfeliz-cruise mfeliz-cruise force-pushed the michael.feliz/dynamic_zeros_like branch from c837942 to ae4244f Compare June 2, 2023 21:05
@github-actions github-actions bot added the component: converters Issues re: Specific op converters label Jun 2, 2023
@narendasan narendasan requested a review from peri044 August 1, 2023 21:43
@mfeliz-cruise mfeliz-cruise force-pushed the michael.feliz/dynamic_zeros_like branch from ae4244f to 864c001 Compare August 2, 2023 18:45
@mfeliz-cruise
Copy link
Contributor Author

@peri044 Should be ready to go.

Copy link
Collaborator

@peri044 peri044 left a comment

Choose a reason for hiding this comment

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

LGTM

@peri044 peri044 merged commit a052cf0 into pytorch:main Aug 5, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: evaluators Issues re: Specific op evaluators component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants