Repository navigation
Conversation
…i] is resolved by premap, a fallback dispatcher hook for the builtins
…dispatcher, FieldOffsetAtIndex in premap
Contributor
Author
|
🤖 Written by an agent on behalf of @havogt |
… this PR (FieldOffset moves to its own PR)
… implements calling them
…ementation of every builtin and its scalar results
…rer names and messages (review)
… no test repeating an import-time assert (review)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ffront.fbuiltins(andffront.experimental) only declare the builtins of the DSL; calling a builtin with values is embedded execution, which the newembedded/builtins.pyimplements.fbuiltinsno longer contains NumPy/mathcomputations or the tuple/named-collection mapping.fbuiltins: declarationsBuiltInFunction.definition(renamed fromfunction) is the declaration: its signature gives__gt_type__, its docstring__doc__. The bodies are....WhereBuiltinFunctionkeeps its overloads, for static typing.BuiltInFunction.__call__hands the call tofbuiltins.call_implementation, a dependency inversion likeiterator.runtime.fendef_embedded. It defaults to raising aRuntimeError, andgt4py.next.embeddedsets it on import.BuiltInFunction.dispatchis gone.embedded/builtins.py: the implementationA call, in order:
whereandconcat_where(the branches) andastype(the value). The mapping and its checks move verbatim fromWhereBuiltinFunction.__call__andastype's body.__gt_builtin_func__, thecommon.Fieldprotocol;NdArrayFieldand its registry are unchanged);cast.An import-time assert checks that every builtin declared in
fbuiltins/experimentalhas a scalar implementation or is field-only (neighbor_sum,max_over,min_over,where,as_offset,concat_where).User-visible changes
astype(math.pi, float32)isnp.float32,abs(-1)isint,gamma(float32)staysfloat32. The tests pin these.TypeErrornaming the builtin. Before, it raised a bareNotImplementedError(where/neighbor_sum/concat_wherewith scalars) or anAssertionError(e.g.sqrt(np.ones(2))).BuiltInFunction.functionis renamed todefinition, andBuiltInFunction.dispatchis removed. Neither has users outsidefbuiltins; icon4py does not use them.BuiltInFunctiondefined with a body no longer runs that body as its implementation. No builtin in gt4py or icon4py did; the test of the idea is removed.Not in this PR
FieldOffset.__getitem__/as_connectivity_fieldstill resolve the offset provider through two function-localembeddedimports. They move to a separate PR.Tests
ffront_tests/test_fbuiltins.py:__gt_type__,nameand__doc__for every builtin;call_implementationwith positional and keyword arguments;RuntimeError;fbuiltinsloads no embedded module (an existing property, now guarded).embedded_tests/test_builtins.py:NdArrayFieldimplementation;TypeErrorfor field-only builtins called with scalars, for an n-d array, and Python's own arity error for too many arguments;where's named-collection and tuple mismatch errors (moved here);whereandastype.Requirements