pub type DynTensor = Value<DynTensorValueType>;
Aliased Type§
struct DynTensor { /* private fields */ }
Implementations§
source§impl DynTensor
impl DynTensor
sourcepub fn from_string_array<T: Utf8Data>(
allocator: &Allocator,
input: impl IntoValueTensor<Item = T>
) -> Result<DynTensor>
pub fn from_string_array<T: Utf8Data>( allocator: &Allocator, input: impl IntoValueTensor<Item = T> ) -> Result<DynTensor>
Construct a Value
from an array of strings.
Just like numeric tensors, string tensor Value
s can be created from:
- (with feature
ndarray
) a shared reference to andarray::CowArray
(&CowArray<'_, T, D>
); - (with feature
ndarray
) a mutable/exclusive reference to anndarray::ArcArray
(&mut ArcArray<T, D>
); - (with feature
ndarray
) an ownedndarray::Array
; - (with feature
ndarray
) a borrowed view of another array, as anndarray::ArrayView
(ArrayView<'_, T, D>
); - a tuple of
(dimensions, data)
where:dimensions
is one ofVec<I>
,[I]
or&[I]
, whereI
isi64
orusize
;- and
data
is one ofVec<T>
,Box<[T]>
,Arc<Box<[T]>>
, or&[T]
.
// You'll need to obtain an `Allocator` from a session in order to create string tensors.
let allocator = session.allocator();
// Create a string tensor from a raw data vector
let data = vec!["hello", "world"];
let value = Value::from_string_array(allocator, ([data.len()], data.into_boxed_slice()))?;
// Create a string tensor from an `ndarray::Array`
#[cfg(feature = "ndarray")]
let value = Value::from_string_array(
allocator,
ndarray::Array::from_shape_vec((1,), vec!["document".to_owned()]).unwrap()
)?;
Note that string data will always be copied, no matter what form the data is provided in.
Trait Implementations§
source§impl<'i, 'v, T: IntoTensorElementType + Debug + Clone + 'static, D: Dimension + 'static> TryFrom<&'i ArrayBase<CowRepr<'v, T>, D>> for DynTensorwhere
'i: 'v,
Available on crate feature ndarray
only.
impl<'i, 'v, T: IntoTensorElementType + Debug + Clone + 'static, D: Dimension + 'static> TryFrom<&'i ArrayBase<CowRepr<'v, T>, D>> for DynTensorwhere
'i: 'v,
Available on crate feature
ndarray
only.source§impl<T: IntoTensorElementType + Debug + Clone + 'static, D: Dimension + 'static> TryFrom<&mut ArrayBase<OwnedArcRepr<T>, D>> for DynTensor
Available on crate feature ndarray
only.
impl<T: IntoTensorElementType + Debug + Clone + 'static, D: Dimension + 'static> TryFrom<&mut ArrayBase<OwnedArcRepr<T>, D>> for DynTensor
Available on crate feature
ndarray
only.source§impl<T: IntoTensorElementType + Debug + Clone + 'static, I: ToDimensions> TryFrom<(I, &[T])> for DynTensor
impl<T: IntoTensorElementType + Debug + Clone + 'static, I: ToDimensions> TryFrom<(I, &[T])> for DynTensor
source§impl<T: IntoTensorElementType + Debug + Clone + 'static, I: ToDimensions> TryFrom<(I, Arc<Box<[T]>>)> for DynTensor
impl<T: IntoTensorElementType + Debug + Clone + 'static, I: ToDimensions> TryFrom<(I, Arc<Box<[T]>>)> for DynTensor
source§impl<T: IntoTensorElementType + Debug + Clone + 'static, I: ToDimensions> TryFrom<(I, Box<[T]>)> for DynTensor
impl<T: IntoTensorElementType + Debug + Clone + 'static, I: ToDimensions> TryFrom<(I, Box<[T]>)> for DynTensor
source§impl<T: IntoTensorElementType + Debug + Clone + 'static, I: ToDimensions> TryFrom<(I, Vec<T>)> for DynTensor
impl<T: IntoTensorElementType + Debug + Clone + 'static, I: ToDimensions> TryFrom<(I, Vec<T>)> for DynTensor
source§impl<T: IntoTensorElementType + Debug + Clone + 'static, D: Dimension + 'static> TryFrom<ArrayBase<OwnedRepr<T>, D>> for DynTensor
Available on crate feature ndarray
only.
impl<T: IntoTensorElementType + Debug + Clone + 'static, D: Dimension + 'static> TryFrom<ArrayBase<OwnedRepr<T>, D>> for DynTensor
Available on crate feature
ndarray
only.