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

Type-selection of xform is wrong when has complex Pars, and converted [o] Pars in flowing xforms don't work #511

Open
7 of 11 tasks
mohawk2 opened this issue Dec 19, 2024 · 0 comments

Comments

@mohawk2
Copy link
Member

mohawk2 commented Dec 19, 2024

This is discussed in https://pdl.perl.org/advent/blog/2024/12/20/pdl-internals/

Type selection

  • The type-selection broke PDL::FFTW3's real -> native complex FFT. The latest has a workaround that avoids using type_coerce. As noted in the article above, the type-detection should correctly detect including for complex Pars, though that should be fixed last after the other issue.
  • The type-selection should prioritise outputs over inputs, since the final results after any potential type-converting will be dictated by them anyway (putting aside questions of operating at higher precision to get more accurate results).
  • Type-selection could be simplified in the one-type case by detecting there's only one type, and just picking that.
  • Restore the 2.095 behaviour of: when no typed (i.e. non-null) outputs, any non-available-typed input will select last-given-type, not an available-typed input type (see github actions failing under PDL-2.096 moocow-the-bovine/PDL-CCS#18 (comment) for test case)

Type conversion

  • When an output must be converted, because its type isn't an available option for that xform, then pdl_converttypei_new would be called with the ndarray params the non-usual way round, with the input null's datatype being set to the xform's, and the output being the original supplied input.
  • In the case where it already has a trans_parent, this would instead cause an error.
  • Forbid null being passed to [io] Pars.

xform inputs from Perl values being made into ndarrays too soon, and thus having a type assigned that requires converting

  • The XS code part of xforms could be enhanced to analyse the supplied Perl parameters, and use the xform spec to determine the required type for each. It could then make ndarrays out of the Perl values with the required type, avoiding the need for conversion.
  • A further benefit from that would be in generating versions of readdata (backward dataflow wouldn't make sense) that only processed Perl SVs, which would avoid overhead in the Perl-value-only scenario (and allow removing the PMCode for log10).

Other thoughts

  • For generated redodims/readdata/writebackdata functions, they should merge the indx and either long or longlong case, since they are functionally identical and it's a bit less code to generate.
  • non-[o] OtherPars should be copied into stack vars at the start of r/w functions, and be forced as rvalues.
mohawk2 added a commit to mohawk2/perl-PDL-IO-Touchstone that referenced this issue Dec 20, 2024
mohawk2 added a commit to PDLPorters/perl5-PGPLOT that referenced this issue Dec 20, 2024
mohawk2 added a commit to mohawk2/PDL-HMM that referenced this issue Dec 20, 2024
mohawk2 added a commit to jlapeyre/PDL-Fit-Levmar that referenced this issue Dec 20, 2024
mohawk2 added a commit to EntropyOrg/p5-Data-Frame that referenced this issue Dec 20, 2024
mohawk2 added a commit to mohawk2/perl5-Test2-Tools-PDL that referenced this issue Dec 20, 2024
mohawk2 added a commit to mohawk2/Photonic that referenced this issue Dec 20, 2024
mohawk2 added a commit to mohawk2/Photonic that referenced this issue Dec 20, 2024
@mohawk2 mohawk2 changed the title Type-detection is wrong for complex Pars, and converted [o] Pars in flowing transforms don't work Type-selection of xform is wrong when has complex Pars, and converted [o] Pars in flowing xforms don't work Dec 22, 2024
mohawk2 added a commit that referenced this issue Dec 23, 2024
mohawk2 added a commit that referenced this issue Dec 26, 2024
mohawk2 added a commit that referenced this issue Dec 26, 2024
mohawk2 added a commit that referenced this issue Dec 26, 2024
mohawk2 added a commit that referenced this issue Dec 26, 2024
mohawk2 added a commit to PDLPorters/PDL-Complex that referenced this issue Dec 27, 2024
mohawk2 added a commit to mohawk2/PDL-Cluster that referenced this issue Dec 29, 2024
moocow-the-bovine added a commit to moocow-the-bovine/PDL-Cluster that referenced this issue Dec 29, 2024
mohawk2 added a commit that referenced this issue Dec 30, 2024
mohawk2 added a commit that referenced this issue Jan 1, 2025
mohawk2 added a commit that referenced this issue Jan 6, 2025
@mohawk2 mohawk2 mentioned this issue Jan 14, 2025
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

1 participant