plenoptic-org / plenoptic

Visualize/test models for visual representation by synthesizing images.
https://plenoptic.readthedocs.io/en/latest/
MIT License
57 stars 9 forks source link

Torch tensor replacements #260

Closed hmd101 closed 3 months ago

hmd101 commented 3 months ago

Replaced torch.tensor with torch.as_tensor in order to save memory. Note that torch.as_tensor only shares the parameters data, dtype, and devicewith torch.tensor, which has additional parameters, such as required_grad. Adjustments were made accordingly.

Example:

data = [1, 2, 3] # can be list, tuple, numpy array, scalar

# will not share memory with original data. Resulting tensor is independent of the input data
tensor_0 = torch.tensor(data) 

# shares memory with original data. Changes of the original data will affect tensor and vice versa
tensor_1 = torch.as_tensor(data) 

Resolves issue #31 .

review-notebook-app[bot] commented 3 months ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 93.75000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 88.53%. Comparing base (efa5c46) to head (cd3211a).

Files Patch % Lines
src/plenoptic/synthesize/synthesis.py 66.66% 1 Missing :warning:
src/plenoptic/tools/signal.py 50.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #260 +/- ## ========================================== - Coverage 88.53% 88.53% -0.01% ========================================== Files 38 38 Lines 3410 3409 -1 ========================================== - Hits 3019 3018 -1 Misses 391 391 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.