Skip to main content

struct

Value

Owns a single reference to a value passed in or out of a model.

Implemented traits

AnyType

Methods

__init__

__init__(inout self: 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__(inout self: 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: Self)

Dispose of this reference to this value.

as_tensor_copy

as_tensor_copy[type: DType](self: Self) -> Tensor[$0]

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: 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: 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.