[code-reflection] RFR: Short cut for single method execution [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Feb 27 10:25:03 UTC 2025
On Thu, 27 Feb 2025 02:32:47 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
>> This allows us to retain the exact method declaration and simply wrap in a lambda (its like an optimization). The execute method requires the user pass the lookup, otherwise reflective access can fail. We can overload using the public lookup if need be later on.
>
> Paul Sandoz has updated the pull request incrementally with one additional commit since the last revision:
>
> Ensure arguments are mapped correctly.
Marked as reviewed by mcimadamore (Reviewer).
cr-examples/onnx/src/main/java/oracle/code/onnx/OnnxRuntime.java line 58:
> 56: }
> 57:
> 58: public static <T> Tensor<T> execute(MethodHandles.Lookup l, OnnxFunction<Tensor<T>> codeLambda) {
The expectation seems to be that the input values are all tensors... maybe we can model them as explicit parameters in the `OnnxFunction` interface - e.g. something like:
interface OnnxFunction<T> {
T apply(Tensor... tensors)
}
This would open the possibility to use method reference in the example -- but one problem is that this uses a raw type (Tensor).
Another option could be to model both the input and output generically:
interface OnnxFunction<T, U> {
T apply(U u)
}
Where both T and U can be either:
* a single Tensor (of any type)
* a list/array of Tensors (again, of any type)
-------------
PR Review: https://git.openjdk.org/babylon/pull/329#pullrequestreview-2647304590
PR Review Comment: https://git.openjdk.org/babylon/pull/329#discussion_r1973294055
More information about the babylon-dev
mailing list