- Calls to a function with inputs of different types (like foo(1) vs foo('hello')). Those are unavoidable.
- Calls to a function with inputs of different sizes. This you can prevent by coder.ignoreSize at call sites. You can create a thin wrapper on the function that contains ignore size and calls the main function, so you don't have to modify each call site.
- Calls to a function with constant inputs of different values (that's where you'd use ignoreConst). This should not happen unless the function really needs those constant inputs.
Is there a way to turn off function specialization for a function or all functions
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nathan Royer
el 16 de Ag. de 2022
Comentada: Jon
el 5 de Mayo de 2023
I do not want any function specialization as I'm targeting code generation for a small memory footprint. Is there a way to turn this off for all fucntions in a project, or for all invocations of a function?
There is coder.ignoreSize and coder.ignoreConst but it requires modifying each invocation of a function to add the coder.ignoreSize or coder.ignoreConst.
0 comentarios
Respuesta aceptada
Denis Gurchenkov
el 16 de Ag. de 2022
Hi Nathan, no, unfortunately there is no blanket way to do so.
Specialization happens in 3 cases:
If you are able to attach an example shoing the pain, what kind of function you have and how it gets unnecesarily specialized, I can pass this to the development team and ask to take into consideration. But for a quick workaround, unfortunately, creating thin wrappers that use coder.ignoreSize and/or Const are the only optins I can think of.
2 comentarios
Jon
el 5 de Mayo de 2023
Nathan, I realize this is probably too late for you ... but today I learned about the undocumented config argument cfg.EnableStructExplosion which prevents just this sort of thing.
(I think in your case, having your function defined as an entry point would also allow you to specify the exact API.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!