-
Notifications
You must be signed in to change notification settings - Fork 11
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
Document batch conventions #38
Comments
Hi @smartalecH, we have some logic which automatically does some broadcasting, here: https://github.com/facebookresearch/fmmax/blob/main/fmmax/fmm.py#L942 I'm not sure your summary above is exactly right, so let me just repeat some of it.
To carry out the calculation you describe, these shapes would indeed work. But, the automatic broadcasting would also allow e.g. the following:
These will then automatically be broadcast up to the shapes you've specified. |
Got it, thanks! Is there a reason the Would it be worth it to augment some of the automatic broadcasting logic to allow the user to specify something like:
that way each quantity only "cares" about shapes related to that quantity? |
Ah, I could have been more clear. There is actually nothing special about
All that matters is that the desired combinations exist when everything is broadcast together. Although simpler logic might be possible, I think it would not be as general. Imagine a case where a user wants to simulate certain wavelength/angle combinations. We could conceivably create some helper functions to reduce the boilerplate, but I don't think we'd want a less general solution at the lowest level. |
Ah yep this put things into context for me, thanks! Adding a blurb about this in the (future) documentation would be useful! |
In the
README.md
, we talk about fmmax's ability to batch over operations. But it would be good to discuss exactly how the user should provide the arrays such that they are properly shaped.In particular, there are three quantities within
eigensolve_isotropic_media
that must have consistent batch dimensions:angular_frequency
(which comes fromwavelength
) with a non-batch dim of[N]
in_plane_wavevector
with a non-batch dim of[2]
permittivity
with a non-batch dim of[N,M]
If the user wants to batch over multiple wavelengths, then they should specify one additional batch dimension in front of these. If the user wants to batch over different
k-points
, then they should specify two additional batch dimensions. If the user wants to loop over a cartesian product of wavelength vectors andk-points
, then they should specify three additional batch dimensions (which obviously must be consistent).So if we wanted to batch over 5 wavelength points, and a 4x4 set of
k-points
, and we have a permittivity image with a size of 100x100 we would expect the following shapes:angular_frequency
-[5, 1, 1]
in_plane_wavevector
-[1, 4, 4, 2]
permittivity
-[1, 1, 1, 100, 100]
@mfschubert does this align with you? Anything else we should add?
The text was updated successfully, but these errors were encountered: