Skip to content

Conversation

@copybara-service
Copy link

[Pallas:MGPU] Add support for jnp.sin

PiperOrigin-RevId: 839326194
Comment on lines +2304 to +2316
@register_lowering_rule(lax.sin_p, mgpu.LoweringSemantics.Lane)
@register_lowering_rule(lax.sin_p, mgpu.LoweringSemantics.Warpgroup)
def _sin_lowering_rule(ctx: LoweringRuleContext, x, accuracy):
if accuracy is not None:
raise NotImplementedError("Not implemented: accuracy")
[x_aval] = ctx.avals_in
if ctx.module_ctx.lowering_semantics == mgpu.LoweringSemantics.Lane:
return _ensure_fa(x, x_aval.dtype).sin(approx=ctx.module_ctx.approx_math)
fastmath = (
arith_dialect.FastMathFlags.afn if ctx.module_ctx.approx_math else None
)
return math_dialect.sin(_ensure_ir_value(x, x_aval.dtype), fastmath=fastmath)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is like a template for all the elementwise ops?

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

Successfully merging this pull request may close these issues.

2 participants