IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo trait

UnsafeFusedView

Flags a fused trait argument whose host and device views share a byte-identical layout.

Conformance here is the legacy gate for the unsafe_fused_view rebind; it exists to keep that one host-built-closure construction compiling while kernels migrate. Prefer the supported pattern in new accelerator kernels: pass the fused trait arg straight through enqueue_function to a device kernel parameterized by XHost: DevicePassable, where the capability is reached via downcast[XHost.device_type, ...]. The canonical exemplars in GraphCompiler/test/kernels/testing_kernels.mojo follow that shape:

  • TraitFusedLoadNegate (_gpu_fused_load_negate_kernel).
  • TraitFusedStoreDouble (_gpu_fused_store_double_kernel).
  • TraitFusedTransformBias (_gpu_fused_transform_bias_kernel).

FusedViewType is the trait's contract field -- the access-enabled view the rebind returns. It is Self.device_type on every conformer today, so the free function next door is the single place the byte-identity check lives. The day the two stop being byte-identical (e.g., NPU), the rebind becomes a real builder on the concrete type and the free function routes through it.

Implemented traitsโ€‹

AnyType, Copyable, Deinitable, Fused, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable

comptime membersโ€‹

FusedViewTypeโ€‹

comptime FusedViewType

Was this page helpful?