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

unsupported operand type(s) for * for dataclass that does not define array_context attribute in compiled_lsrk45 #289

Open
majosm opened this issue Sep 30, 2022 · 1 comment

Comments

@majosm
Copy link
Collaborator

majosm commented Sep 30, 2022

@anderson2981 ran into an error in the wall-enabled prediction driver when using compiled_lsrk45:

  File "emirge/mirgecom/mirgecom/steppers.py", line 425, in advance_state
    _advance_state_stepper_func(
  File "emirge/mirgecom/mirgecom/steppers.py", line 159, in _advance_state_stepper_func
    state = timestepper(state=state, t=t, dt=dt, rhs=compiled_rhs)
  File "prediction.py", line 1471, in _compiled_stepper_wrapper
    return compiled_lsrk45_step(actx, state, t, dt, rhs)
  File "emirge/grudge/grudge/shortcuts.py", line 58, in compiled_lsrk45_step
    y, residual = update(y, a, b, h, rhs_val)
  File "emirge/arraycontext/arraycontext/impl/pytato/compile.py", line 336, in __call__
    output_template = self.f(
  File "emirge/grudge/grudge/shortcuts.py", line 38, in _lsrk45_update
    residual = a*residual + h*rhs_val
TypeError: unsupported operand type(s) for *: 'Placeholder' and 'WallVars'

Here WallVars is a dataclass defined in a similar manner to ConservedVars, with (at least) one distinction: it does not define an array_context method (and does not set _cls_has_array_context_attr=True) (code).

The above error doesn't occur with the regular rk4_step, and it also goes away if I define an array_context method in WallVars. Is this a bug, or is there a reason that it needs to define an array_context method in order to work?

@kaushikcfd
Copy link
Collaborator

kaushikcfd commented Sep 30, 2022

For this behavior of broadcasting ArrayContext.array_types across a container, _bcast_actx_array_type needs to be set. The behavior observed here agrees with the docs (see the default values of _bcast_actx_array_type).

For this feature, we require array_context to be an attribute to figure out which array types could be legally broadcasted.

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

2 participants