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

Missing externals feedback #50

Open
2 tasks
FlorianDeconinck opened this issue Jun 11, 2024 · 0 comments
Open
2 tasks

Missing externals feedback #50

FlorianDeconinck opened this issue Jun 11, 2024 · 0 comments

Comments

@FlorianDeconinck
Copy link
Collaborator

FlorianDeconinck commented Jun 11, 2024

When a variable is unknown, gt4py.cartesian expects it to be defined via the __externals__ mechanism. This in itself could be the subject of a ticket, but here we will assume it's the right behavior.

When the undefined variable is from a stencil the error is mildly helpful

gt4py.cartesian.frontend.exceptions.GTScriptSymbolError: Unknown symbol 'UNDEF_VAR' symbol in '<source>' (line: 3, col: 32)

The <source> field should at least give a stencil name. Running with build_info["debug"]=True doesn't help.

When the undefined variable is from a gtscript.function the error is even less readable:

gt4py.cartesian.frontend.exceptions.GTScriptSymbolError: Unknown symbol ValueError symbol in '<source>' (line: 5, col: 20)

Example code:

import gt4py.cartesian.gtscript as gtscript
from gt4py.cartesian.gtscript import (
    computation,
    interval,
    PARALLEL
)
from ndsl.boilerplate import get_factories_single_tile_numpy
from ndsl.constants import X_DIM, Y_DIM, Z_DIM
from ndsl.dsl.typing import FloatField 

stcil_fctry, qty_fctry = get_factories_single_tile_numpy(5, 5, 1, 1)

out_q = qty_fctry.zeros([X_DIM, Y_DIM, Z_DIM], "n/a")
in_q = qty_fctry.ones([X_DIM, Y_DIM, Z_DIM], "n/a")

@gtscript.function
def add_one(field: FloatField) -> FloatField:
    # from __externals__ import UNDEF_CST

    return field + UNDEF_CST

def copy(in_field: FloatField, out_field: FloatField):
    with computation(PARALLEL), interval(...):
        out_field = in_field + add_one(in_field)

copy_stcil = stcil_fctry.from_dims_halo(
    func=copy,
    compute_dims=[X_DIM, Y_DIM, Z_DIM],
    # externals={
    #     "UNDEF_CST": 5
    # }
)

copy_stcil(in_q, out_q)

Parent: #49


  • Missing external in stencil reports name of the stencil
  • Missing external in gtscript.function reports name of the function or at least calling stencil
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