#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SemanticProfile {
Creation,
UnaryFloat,
BinaryBroadcast,
Comparison,
Logical,
Mutation,
Shape,
Selection,
Indexing,
MatMul,
Attention,
Reduction,
IndexReduction,
Scan,
Normalization,
Module,
Composite,
Loss,
Quantized,
Optimizer,
Transfer,
Autograd,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum BroadcastingRule {
None,
Numpy,
ExplicitTarget,
TypedContract,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum DTypeRule {
Preserve,
Floating,
NumericSame,
Boolean,
BooleanResult,
IndexResult,
ExplicitOutput,
Quantized,
TypedContract,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum OutputRule {
Created,
Preserve,
Broadcast,
ShapeAttributes,
Reduction,
MatMul,
Indexing,
ExplicitDType,
TypedInference,
DataDependent,
HostValue,
}
impl OutputRule {
pub const fn is_data_dependent(self) -> bool {
matches!(self, Self::DataDependent)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum EmptyRule {
Allowed,
IdentityOrDefined,
RejectedWhenReductionIsEmpty,
TypedContract,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum NumericRule {
NotApplicable,
IeeePropagate,
CheckedInteger,
StableAccumulation,
TypedContract,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum GradientRule {
None,
Defined,
Piecewise,
Undefined,
TypedContract,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum LayoutRule {
FreshContiguous,
ViewWhenPossible,
PreserveOrMaterialize,
TypedContract,
HostOnly,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub enum ExecutionSite {
Kernel,
Creation,
HostReadback,
Composed,
Mutation,
DeviceTransfer,
GraphState,
}
impl ExecutionSite {
#[must_use]
pub const fn is_backend_executable(self) -> bool {
matches!(self, Self::Kernel | Self::Creation | Self::HostReadback)
}
pub const fn blocking_reason(self) -> Option<&'static str> {
match self {
Self::Kernel | Self::Creation | Self::HostReadback => None,
Self::Composed => Some("the frontend composition owns the execution semantics"),
Self::Mutation => Some("writes through an operand; execution borrows operands shared"),
Self::DeviceTransfer => {
Some("produces storage on another backend, which the executor cannot name")
}
Self::GraphState => Some("acts on autograd state, not on an allocation"),
}
}
}