-
Notifications
You must be signed in to change notification settings - Fork 670
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
Add Ray tracing method for RIR (#2850) #3234
base: main
Are you sure you want to change the base?
Conversation
This pull request was exported from Phabricator. Differential Revision: D41764237 |
cc @fakufaku @JupiterEthan ray_tracing function should be ready, would like to hear thoughts from you. Thanks! |
const torch::Tensor& _absorption, | ||
const torch::Tensor& _scattering, | ||
const torch::Tensor& _normal, | ||
const torch::Tensor& _origin) | ||
: absorption(std::move(_absorption)), | ||
reflection((scalar_t)1. - _absorption), | ||
scattering(std::move(_scattering)), | ||
normal(std::move(_normal)), | ||
origin(std::move(_origin)) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applying std::move
to const
reference is strange.
You can probably remove std::move
and copy construct them.
torch::Tensor get_absorption() { | ||
return absorption; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems not used.
torch::Tensor get_reflection() { | ||
return reflection; | ||
} | ||
torch::Tensor get_scattering() { | ||
return scattering; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, making it a attribute and accessing directly would do.
false; // TODO: remove this once hybrid method is supported | ||
const int ISM_ORDER = 10; // TODO: remove this once ISM method is supported | ||
#define EPS ((scalar_t)(1e-5)) | ||
#define VAL(t) (*((t).template data_ptr<scalar_t>())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this macro is necessary. Simply calling item
method should do.
auto num_mics = mic_array.size(0); | ||
auto num_bands = absorption.size(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot call size(0)
, without first checking the ndim >= 1
scalar_t _energy_thres, | ||
scalar_t _time_thres, | ||
scalar_t _hist_bin_size) | ||
: room(_room), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the dimension of room is not checked.
time_thres(_time_thres), | ||
hist_bin_size(_hist_bin_size), | ||
max_dist(VAL(room.norm()) + (scalar_t)1.), | ||
D(room.size(0)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D is unbounded. Need validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather, I'd make D a template parameter.
|
||
assert hist.shape == expected_shape | ||
|
||
def test_ray_tracing_input_errors(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need more of these. currently the implementation does not reject the invalid shapes like empty tensors.
scattering=scattering, | ||
) | ||
|
||
assert hist.shape == expected_shape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use self.assertEqual
. (Buck does not report numbers with assert
)
/** | ||
* The main (and only) public entry point of this class. The histograms Tensor | ||
* reference is passed along and modified in the subsequent private method | ||
* calls. This method spawns num_rays rays in all directions from the source | ||
* and calls simul_ray() on each of them. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use //
for comment so that later it's easy to block the whole thing
histograms = histograms.transpose( | ||
1, 2); // back into shape (num_mics, num_bands, num_bins) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the comment to separate line? It's easier to read that way.
travel_dist += hit_distance; | ||
transmitted *= wall.get_reflection(); | ||
|
||
// Let's shoot the scattered ray induced by the rebound on the wall |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Let's shoot the scattered ray induced by the rebound on the wall | |
// Let's shoot the scattered ray induced by the rebound on the wall |
const bool IS_HYBRID_SIM = | ||
false; // TODO: remove this once hybrid method is supported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move the comment to separate line
0be21fb
to
57ddebf
Compare
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/audio/3234
Note: Links to docs will display an error until the docs builds have been completed. ❌ 7 New FailuresAs of commit ca69eaa with merge base 5e893d6 (): NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Summary: This PR adds the `ray_tracing()` helper to compute a RIR (part of pytorch#2624). The implementation is heavily based on `pyroomacoustics`. Differential Revision: D41764237 Pulled By: nateanl
This pull request was exported from Phabricator. Differential Revision: D41764237 |
} | ||
|
||
if (intersection_found) { | ||
next_wall_index = 2 * d[0] + ind_inc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nateanl I feel like this should be d[0] + 2 * ind_inc
. Do we have test to verify this is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nateanl Actually, this is correct for 3D but not for 2D. Because for 2D the order of wall is SENW, while for 3D it's WESNCF.
Summary: This PR adds the `ray_tracing()` helper to compute a RIR (part of pytorch#2624). The implementation is heavily based on `pyroomacoustics`. Differential Revision: D41764237 Pulled By: nateanl
57ddebf
to
ca69eaa
Compare
This pull request was exported from Phabricator. Differential Revision: D41764237 |
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary: Revamped version of pytorch#3234 (which was also revamp of pytorch#2850) Differential Revision: D49197174 Pulled By: mthrok
Summary:
This PR adds the
ray_tracing()
helper to compute a RIR (part of #2624). The implementation is heavily based onpyroomacoustics
.Pull Request resolved: #2850
Differential Revision: D41764237
Pulled By: nateanl