Skip to content

5211 5214 infer device from first item RandElastic, simplify first_key() default#5213

Merged
wyli merged 3 commits intoProject-MONAI:devfrom
wyli:5211-elastic-device
Sep 27, 2022
Merged

5211 5214 infer device from first item RandElastic, simplify first_key() default#5213
wyli merged 3 commits intoProject-MONAI:devfrom
wyli:5211-elastic-device

Conversation

@wyli
Copy link
Copy Markdown
Contributor

@wyli wyli commented Sep 26, 2022

Signed-off-by: Wenqi Li [email protected]

Fixes #5211
Fixes #5214

Description

  • set device based on the first item:
device = self.rand_2d_elastic.device
if device is None and isinstance(d[first_key], torch.Tensor):
    device = d[first_key].device  # type: ignore
    self.rand_2d_elastic.set_device(device)
  • simplied transform first_key() default to a tuple

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
@wyli wyli changed the title 5211 infer device from first item RandElastic, simplify first_key() default 5211 5214 infer device from first item RandElastic, simplify first_key() default Sep 26, 2022
@wyli wyli marked this pull request as ready for review September 26, 2022 18:16
Copy link
Copy Markdown
Contributor

@Nic-Ma Nic-Ma 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 the quick fix, looks good to me.

@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Sep 27, 2022

/build

Signed-off-by: Wenqi Li <[email protected]>
@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Sep 27, 2022

/build

@wyli wyli enabled auto-merge (squash) September 27, 2022 07:51
@wyli wyli merged commit 0d89494 into Project-MONAI:dev Sep 27, 2022
@wyli wyli deleted the 5211-elastic-device branch October 5, 2022 11:42
wyli added a commit that referenced this pull request Oct 10, 2022
…ey()` default (#5213)

Signed-off-by: Wenqi Li <[email protected]>

Fixes #5211
Fixes #5214

### Description
- set device based on the first item:
```py
device = self.rand_2d_elastic.device
if device is None and isinstance(d[first_key], torch.Tensor):
    device = d[first_key].device  # type: ignore
    self.rand_2d_elastic.set_device(device)
```

- simplied transform `first_key()` default to a tuple

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
KumoLiu pushed a commit that referenced this pull request Nov 2, 2022
…ey()` default (#5213)

Signed-off-by: Wenqi Li <[email protected]>

Fixes #5211
Fixes #5214

### Description
- set device based on the first item:
```py
device = self.rand_2d_elastic.device
if device is None and isinstance(d[first_key], torch.Tensor):
    device = d[first_key].device  # type: ignore
    self.rand_2d_elastic.set_device(device)
```

- simplied transform `first_key()` default to a tuple

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: KumoLiu <[email protected]>
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.

make the default value of first_key hashable Rand3DElasticd does not use correct device

2 participants