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

orix.sampling.get_sample_local() is quite memory intensitve #175

Closed
hakonanes opened this issue Apr 21, 2021 · 8 comments
Closed

orix.sampling.get_sample_local() is quite memory intensitve #175

hakonanes opened this issue Apr 21, 2021 · 8 comments
Milestone

Comments

@hakonanes
Copy link
Member

hakonanes commented Apr 21, 2021

This code fills my 16 GB memory (from 6 GB used before running) immediately

>>> import numpy as np
>>> from orix import sampling, quaternion
>>> r = quaternion.Rotation.from_euler(np.deg2rad([133.3, 88.7, 177.8]))
>>> r2 = sampling.get_sample_local(resolution=0.5, center=r, grid_width=5)

Am I wrong in assuming that this code would give me about 5^3 / 0.5 = 250 rotations about r? If I'm right, we should revisit the implementation of get_sample_local().

@pc494
Copy link
Member

pc494 commented Apr 21, 2021

Resolution is a difficult concept here, so I won't speculate about how many rotations you might actually expect. But the current implementation is very naive (it samples all of orientation space then cuts it back down).

I think I could improve upon this.

@hakonanes
Copy link
Member Author

Understandable. But 250 is a reasoanble estimate, give or take, I would assume.

I haven't used this function before now, but I believe it can be usefuly in our work. I would be happy to assist.

@pc494
Copy link
Member

pc494 commented Apr 21, 2021

The basic problems were:

  1. Sampling uniformly while retaining a constraint (ie. rather than using a rejection based sampling).
  2. Not introducing randomness (eg. Any method that involves a Gaussian)

I'm currently having a look and I think we probably could improve things

@pc494
Copy link
Member

pc494 commented Apr 21, 2021

Okay, I've now got an idea, could probably get this done for the start of next week, would that be okay?

[1] - http://planning.cs.uiuc.edu/node198.html
[2] - http://inis.jinr.ru/sl/vol1/CMC/Graphics_Gems_3,ed_D.Kirk.pdf (starting at page 156 of the pdf)

@hakonanes
Copy link
Member Author

Yeah, totally, there is no rush on this!

@hakonanes
Copy link
Member Author

I believe Object3d.unique() is the source for the memory error, which I see by trying out #175 as well (will finish review on Sunday). I think there is room for improvement in that method, I will have a look at that hopefully next week.

@pc494
Copy link
Member

pc494 commented Apr 30, 2021

I believe Object3d.unique() is the source for the memory error, which I see by trying out #175 as well (will finish review on Sunday). I think there is room for improvement in that method, I will have a look at that hopefully next week.

"""Returns a new object containing only this object's unique entries."""

Yeah that'll double the usage, but I think #175 should still make it a lot smaller.

@hakonanes hakonanes added this to the v0.6.0 milestone May 6, 2021
pc494 added a commit that referenced this issue May 7, 2021
Improving the performance of the samplings utils (see #175)
@pc494
Copy link
Member

pc494 commented May 7, 2021

Closed by #177

@pc494 pc494 closed this as completed May 7, 2021
@pc494 pc494 mentioned this issue May 16, 2021
7 tasks
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

No branches or pull requests

2 participants