Skip to content

[Routines] Update Exponents & Extrema with HostExecutor#332

Merged
forfudan merged 31 commits into
Mojo-Numerics-and-Algorithms-group:pre-0.9from
shivasankarka:expo_extrema
Mar 11, 2026
Merged

[Routines] Update Exponents & Extrema with HostExecutor#332
forfudan merged 31 commits into
Mojo-Numerics-and-Algorithms-group:pre-0.9from
shivasankarka:expo_extrema

Conversation

@shivasankarka
Copy link
Copy Markdown
Collaborator

@shivasankarka shivasankarka commented Mar 7, 2026

This PR does the following (#328 ),

  • Replace all instances of backend() with HostExecutor in exponent and extrema functions. For functions that don't use backend(), replace those with appropriate HostExecutor overload.
  • Add where dtype.is_floating_point() constraint to all functions that internally make use of building mojo math functions.

@shivasankarka shivasankarka marked this pull request as draft March 7, 2026 03:39
shivasankarka and others added 6 commits March 10, 2026 19:32
…lgorithms-group#331)

This PR does the following (Mojo-Numerics-and-Algorithms-group#328 ), 
- Update backend with `apply_ternary` function which as of now is used
for Fused Multiply Add (FMA) operations of three arrays or two arrays
and a scalar.
- Replace all instances of `backend()` with `HostExecutor` in arithmetic
functions.
…Algorithms-group#334)

`@parameter if` is being deprecated in favor of `comptime if`.
…and-Algorithms-group#335)

`DeviceStorage` cannot be implicitly copied in mojo stdlib versions at or
after dev2026022817
…gorithms-group#338)

## Replace Deprecated Traits with `Writable`

- **Representable → Writable**: Replaces deprecated `Representable` with
`Writable`.
- **Stringable → Writable**: Replaces deprecated `Stringable` with
`Writable`.

## Bug Fixes

- **Recursive stringification in `NDArrayStrides`**: Fixes infinite
recursion when `write_to` used `String(self)`, which re-entered
`write_to`. Switched to `self.__str__()` in both `__repr__` and
`write_to` to avoid recursion.

- **`Device` and `repr()`**: Adds `write_repr_to` to `Device`. Mojo's
`repr()` now calls `write_repr_to` instead of `__repr__`, which was
causing failures in `tests/core/test_device.mojo`.
…errors, plus import issue (Mojo-Numerics-and-Algorithms-group#339)

# Mojo Compatibility Updates

## Dependency Update

- **Modular version**: Bump to `26.2.0.dev2026030605`.

## Bug Fixes

### VariadicList `is_owned` parameter

- Unbinds the `is_owned` parameter on `VariadicList` usage to fix
inference failures.

### SIMD.fma and `apply_ternary` type mismatch

- Fixes a type mismatch where `SIMD.fma` would not match on
`apply_ternary` because the kernel function has a `flag: FastMathFlag =
FastMathFlag.CONTRACT` parameter.
- Default values do not prevent type mismatch errors in this context.
- `apply_ternary` expects `fn[DType, Int](SIMD, SIMD, SIMD) -> SIMD`,
but `SIMD.fma` has signature `fn[DType, Int, +, flag: FastMathFlag =
...](self, multiplier, accumulator) -> SIMD`.
- Likely caused by changes in [modular/mojo stdlib
simd.mojo](https://github.com/modular/modular/blame/1ce7b57a4cac057803a54bcaa023f114eb4f7b3d/mojo/stdlib/std/builtin/simd.mojo#L274).

---------

Co-authored-by: shivasankar <shivasankar.ka@gmail.com>
@shivasankarka shivasankarka marked this pull request as ready for review March 11, 2026 13:16
@shivasankarka shivasankarka requested a review from forfudan March 11, 2026 13:22
@shivasankarka shivasankarka marked this pull request as draft March 11, 2026 13:23
@shivasankarka shivasankarka marked this pull request as ready for review March 11, 2026 13:26
Copy link
Copy Markdown
Collaborator

@forfudan forfudan left a comment

Choose a reason for hiding this comment

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

@shivasankarka There are some minor issues but not blocking. I will approve and merge this PR first and then deal with them in another PR later.

@forfudan forfudan merged commit 9d0fab3 into Mojo-Numerics-and-Algorithms-group:pre-0.9 Mar 11, 2026
2 checks passed
forfudan pushed a commit that referenced this pull request Mar 31, 2026
This PR does the following (#328 ),

- Replace all instances of backend() with HostExecutor in `exponent` and
`extrema` functions. For functions that don't use backend(), replace
those with appropriate `HostExecutor` overload.
- Add `where dtype.is_floating_point()` constraint to all functions that
internally make use of building mojo math functions.

---------

Co-authored-by: josiahls <josiahls@users.noreply.github.com>
@shivasankarka shivasankarka deleted the expo_extrema branch May 15, 2026 02:36
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.

3 participants