Mojo struct
Value
struct Value
Owns a single reference to a value passed in or out of a model.
Implemented traits
AnyType
,
UnknownDestructibility
Methods
__init__
__init__(out self, ptr: CValue, lib: DLHandle, owned session: InferenceSession)
Internal use only.
To create values yourself, use new_*_value
methods on
InferenceSession
.
Args:
- ptr (
CValue
): Internal use only. - lib (
DLHandle
): Internal use only. - session (
InferenceSession
): Internal use only.
__moveinit__
__moveinit__(out self, owned existing: Self)
Take ownership of the value contained in another Value
.
Args:
- existing (
Self
): The value to take ownership of.
__del__
__del__(owned self)
Dispose of this reference to this value.
as_tensor_copy
as_tensor_copy[type: DType](self) -> Tensor[type]
Return a copy of the tensor contained in this value.
Parameters:
- type (
DType
): The expected DType of the tensor.
Returns:
A copy of the tensor contained in this value.
Raises:
If the value is not a tensor, or the dtype of the tensor value is mismatched with the provided type.
as_bool
as_bool(self) -> Bool
Get the boolean contained in this value.
The result is undefined if this value is not a boolean.
Returns:
Boolean contained in this value.
as_list
as_list(self) -> List
Borrow the list contained in this value.
Ownership of the list is not transferred. User must ensure the value outlives the list.
Returns:
A List
borrowing the internal storage of this value.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!