pub struct Target { /* private fields */ }Expand description
A compilation target: its kind, the keys that classify it, such as cpu, the attrs of
its options, and an optional host target for the code that runs on the host. A target may come
from a registered tag, such as nvidia/nvidia-a100.
§Examples
use tvm_tirx::target::Target;
let cpu = Target::new(r#"{"kind": "llvm", "mcpu": "skylake"}"#)?;
assert!(cpu.as_json()?.as_str().contains(r#""keys":["cpu"]"#));Implementations§
Source§impl Target
impl Target
Sourcepub fn new(target: &str) -> Result<Self>
pub fn new(target: &str) -> Result<Self>
Create the target that a tag ("nvidia/nvidia-a100"), a kind name ("llvm") or a JSON
config describes (target.Target).
§Errors
Returns an error if the tag or the kind is not registered, or the JSON config is invalid.
Sourcepub fn from_config(config: impl Into<Map<String, Any>>) -> Result<Self>
pub fn from_config(config: impl Into<Map<String, Any>>) -> Result<Self>
Create the target that a config map describes, such as {"kind": "cuda", "arch": "sm_80"}
or a tag with attribute overrides (target.Target).
The two-target form of target.Target, a target with a host, is Target::with_host.
§Errors
Returns an error if the config is invalid, as new does.
Sourcepub fn export(&self) -> Result<Map<String, Any>>
pub fn export(&self) -> Result<Map<String, Any>>
Return the config map that describes the target (target.TargetExport).
Sourcepub fn as_json(&self) -> Result<String>
pub fn as_json(&self) -> Result<String>
Return the target as JSON, which new parses back (target.TargetAsJSON).
Sourcepub fn with_host(&self, host: Option<&Target>) -> Result<Self>
pub fn with_host(&self, host: Option<&Target>) -> Result<Self>
Return a copy of the target with host as its host, or none (target.WithHost).
Sourcepub fn get_target_device_type(&self) -> Result<i32>
pub fn get_target_device_type(&self) -> Result<i32>
Return the DLDeviceType of the devices the target runs on (target.TargetGetDeviceType).
Sourcepub fn feature(&self, name: &str) -> Result<Option<Any>>
pub fn feature(&self, name: &str) -> Result<Option<Any>>
Return the feature.<name> attribute of the target, or None when it has none
(target.TargetGetFeature).
Sourcepub fn list_kinds() -> Result<Array<String>>
pub fn list_kinds() -> Result<Array<String>>
Return the names of the registered target kinds (target.ListTargetKinds).
Trait Implementations§
Source§impl DowncastRefFromAny for Target
impl DowncastRefFromAny for Target
Source§unsafe fn downcast_ref_from_any(cell: &TVMFFIAny) -> Option<&Self>
unsafe fn downcast_ref_from_any(cell: &TVMFFIAny) -> Option<&Self>
Source§impl ObjectRefAnyCompatible for Target
impl ObjectRefAnyCompatible for Target
Source§fn extra_check(obj: &Self::ContainerType) -> bool
fn extra_check(obj: &Self::ContainerType) -> bool
obj, an instance of ContainerType, is a value of Self.
Every strict and converting cast checks it, after the object type.Source§fn convert_fallback(value: AnyView<'_>) -> Option<Self>
fn convert_fallback(value: AnyView<'_>) -> Option<Self>
Self object, such as an integer that
stands for a constant; None rejects it. Only converting casts (TryFrom<Any>,
typed function arguments) call it; downcast_ref, downcast and
match_any! never do.Source§fn custom_type_str() -> String
fn custom_type_str() -> String
AnyCompatible::type_str.Source§fn custom_mismatch_type_info(value: AnyView<'_>) -> String
fn custom_mismatch_type_info(value: AnyView<'_>) -> String
value in conversion errors; by default its
runtime type key. See AnyCompatible::get_mismatch_type_info.Source§impl ObjectRefCore for Target
impl ObjectRefCore for Target
Source§type ContainerType = TargetObj
type ContainerType = TargetObj
Source§fn data(this: &Self) -> &ObjectArc<Self::ContainerType>
fn data(this: &Self) -> &ObjectArc<Self::ContainerType>
Source§fn into_data(this: Self) -> ObjectArc<Self::ContainerType>
fn into_data(this: Self) -> ObjectArc<Self::ContainerType>
Source§unsafe fn from_data(data: ObjectArc<Self::ContainerType>) -> Self
unsafe fn from_data(data: ObjectArc<Self::ContainerType>) -> Self
Source§fn same_as<Other>(&self, other: &Other) -> boolwhere
Other: ObjectRefCore,
fn same_as<Other>(&self, other: &Other) -> boolwhere
Other: ObjectRefCore,
Source§fn type_key(&self) -> &'static str
fn type_key(&self) -> &'static str
"ffi.Array", as C++ ObjectRef::GetTypeKey.Source§fn is<T>(&self) -> boolwhere
T: AnyCompatible,
fn is<T>(&self) -> boolwhere
T: AnyCompatible,
T as is, such as a subtype or a container
whose elements are checked too, by the strict check of
downcast, without a reference count change.
See also crate::Any::is.Source§impl<'a> PackedCallArg for &'a Target
impl<'a> PackedCallArg for &'a Target
Source§impl PackedCallArg for Target
impl PackedCallArg for Target
impl TypeSubsumes<Target> for ObjectRef
Auto Trait Implementations§
impl Freeze for Target
impl RefUnwindSafe for Target
impl !Send for Target
impl !Sync for Target
impl Unpin for Target
impl UnsafeUnpin for Target
impl UnwindSafe for Target
Blanket Implementations§
Source§impl<T> AnyCompatible for Twhere
T: ObjectRefAnyCompatible,
impl<T> AnyCompatible for Twhere
T: ObjectRefAnyCompatible,
const MATCH_ANY_EXACT: bool
fn match_any_exact_type_index() -> i32
Source§unsafe fn is_undefined(field: *const T) -> bool
unsafe fn is_undefined(field: *const T) -> bool
field, which holds a value of this type or all-zero bytes,
holds all-zero bytes that are no value of this type, as a null object
reference, a string of type index None or a zero device type: a field
that a creator left undefined for reflection to set. An undefined field
is no value; a nullable reference is Option<T>, whose None is a
defined value. Read moreSource§unsafe fn copy_to_any_view(src: &T, data: &mut TVMFFIAny)
unsafe fn copy_to_any_view(src: &T, data: &mut TVMFFIAny)
Source§unsafe fn move_to_any(src: T, data: &mut TVMFFIAny)
unsafe fn move_to_any(src: T, data: &mut TVMFFIAny)
Source§unsafe fn check_any_strict(data: &TVMFFIAny) -> bool
unsafe fn check_any_strict(data: &TVMFFIAny) -> bool
Source§unsafe fn copy_from_any_view_after_check(data: &TVMFFIAny) -> T
unsafe fn copy_from_any_view_after_check(data: &TVMFFIAny) -> T
Self out of a cell that holds one, retaining any object. Read moreSource§unsafe fn move_from_any_after_check(data: &mut TVMFFIAny) -> T
unsafe fn move_from_any_after_check(data: &mut TVMFFIAny) -> T
Self out of an owning cell that holds one. Read moreSource§unsafe fn try_cast_from_any_view(data: &TVMFFIAny) -> Result<T, ()>
unsafe fn try_cast_from_any_view(data: &TVMFFIAny) -> Result<T, ()>
data into a Self by the FFI rules, such as an integer into a
float; Err if it does not convert. Read moreSource§fn get_mismatch_type_info(data: &TVMFFIAny) -> String
fn get_mismatch_type_info(data: &TVMFFIAny) -> String
data in conversion errors; by
default its runtime type key.Source§fn type_str() -> String
fn type_str() -> String
int,
ffi.String or Array<int>.Source§fn type_schema() -> String
fn type_schema() -> String
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, S> IntoExpr<T> for S
impl<T, S> IntoExpr<T> for S
Source§type Output = <S as IntoArg<T>>::Output
type Output = <S as IntoArg<T>>::Output
T for an owned value or a literal, or a borrowed &T for a
reference, which converts without a reference-count change. Read moreSource§fn into_expr(self) -> Result<<S as IntoArg<T>>::Output, Error>
fn into_expr(self) -> Result<<S as IntoArg<T>>::Output, Error>
ExprResult raised.Source§fn into_owned_expr(self) -> Result<T>where
Self: Sized,
fn into_owned_expr(self) -> Result<T>where
Self: Sized,
Cow::into_owned
does: an owned value moves, and only a borrowed expression is cloned.