Skip to main content

DLDataTypeExt

Trait DLDataTypeExt 

Source
pub trait DLDataTypeExt: Sized {
    // Required methods
    fn to_string(&self) -> String;
    fn try_from_str(dtype_str: &str) -> Result<Self>;
}
Expand description

Name conversions of a DLDataType.

Required Methods§

Source

fn to_string(&self) -> String

Return the name of the data type, such as "int32", "float64" or "int8x4" (bits and lanes), the name every language uses for it, or "dtype(code=.., bits=.., lanes=..)" for one the runtime cannot name.

use tvm_ffi::{DLDataType, DLDataTypeExt};
let dtype = DLDataType::try_from_str("float16")?;
assert_eq!(dtype.to_string(), "float16");
Source

fn try_from_str(dtype_str: &str) -> Result<Self>

Parse a data type from its name, the inverse of to_string.

§Arguments
  • dtype_str - The name, such as "int32".
§Returns

The data type.

§Errors

If the name is not a data type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§