Mojo struct
DeviceContextPtr
@register_passable(trivial)
struct DeviceContextPtr
Exposes a pointer to a C++ DeviceContext to Mojo.
Note: When initializing a DeviceContext from a pointer, the refcount is not
incremented. This is considered safe because get_device_context()
is only used within kernels and the DeviceContext lifetime is managed
by the graph compiler.
Implemented traits
AnyType,
Copyable,
Defaultable,
ImplicitlyCopyable,
Movable,
UnknownDestructibility
Aliases
__copyinit__is_trivial
alias __copyinit__is_trivial = True
__del__is_trivial
alias __del__is_trivial = True
__moveinit__is_trivial
alias __moveinit__is_trivial = True
Methods
__init__
__init__() -> Self
Initialize an empty DeviceContextPtr with a null pointer.
This creates a DeviceContextPtr that doesn't point to any device context.
__init__(handle: UnsafePointer[NoneType]) -> Self
Initialize a DeviceContextPtr from a raw pointer.
Args:
- handle (
UnsafePointer): A raw pointer to a C++DeviceContext.
@implicit
__init__(device: DeviceContext) -> Self
Initialize a DeviceContextPtr from a DeviceContext.
This constructor allows implicit conversion from DeviceContext to DeviceContextPtr.
Args:
- device (
DeviceContext): TheDeviceContextto wrap in this pointer.
__getitem__
__getitem__(self) -> DeviceContext
Dereference the pointer to get the DeviceContext.
Returns:
DeviceContext: The DeviceContext that this pointer points to.
get_device_context
get_device_context(self) -> DeviceContext
Get the DeviceContext that this pointer points to.
This is an alias for the dereference operator.
Returns:
DeviceContext: The DeviceContext that this pointer points to.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!