pub struct TensorOpScheduler {
pub ops: HashMap<u64, TensorOp>,
/* private fields */
}Expand description
Priority-based tensor operation scheduler with dependency tracking.
See the module-level documentation for a full usage example.
Fields§
§ops: HashMap<u64, TensorOp>All registered operations keyed by op_id.
Implementations§
Source§impl TensorOpScheduler
impl TensorOpScheduler
Sourcepub fn enqueue(
&mut self,
name: String,
priority: OpPriority,
deps: Vec<u64>,
flops: u64,
) -> u64
pub fn enqueue( &mut self, name: String, priority: OpPriority, deps: Vec<u64>, flops: u64, ) -> u64
Enqueues a new operation and returns its assigned op_id.
The operation starts in OpStatus::Pending regardless of whether its
dependency list is empty. Call advance_tick to
promote operations with satisfied dependencies to OpStatus::Ready.
§Arguments
name– Human-readable operation name.priority– Scheduling priority.deps– IDs of operations that must complete before this one runs.flops– Estimated floating-point operations for resource accounting.
Sourcepub fn advance_tick(&mut self)
pub fn advance_tick(&mut self)
Advances the scheduler tick by one and re-evaluates dependency readiness.
Each OpStatus::Pending operation whose every dependency is in
OpStatus::Completed is promoted to OpStatus::Ready.
Sourcepub fn start_op(&mut self, op_id: u64) -> bool
pub fn start_op(&mut self, op_id: u64) -> bool
Attempts to transition the operation to OpStatus::Running.
Returns true on success. Returns false if the operation does not
exist or is not in OpStatus::Ready state.
Sourcepub fn complete_op(&mut self, op_id: u64) -> bool
pub fn complete_op(&mut self, op_id: u64) -> bool
Attempts to transition the operation to OpStatus::Completed.
Returns true on success. Returns false if the operation does not
exist or is not in OpStatus::Running state.
Sourcepub fn fail_op(&mut self, op_id: u64, reason: String) -> bool
pub fn fail_op(&mut self, op_id: u64, reason: String) -> bool
Attempts to transition the operation to OpStatus::Failed.
The operation must be in OpStatus::Running or OpStatus::Ready
state. Returns true on success, false otherwise.
Sourcepub fn next_ready(&self) -> Option<u64>
pub fn next_ready(&self) -> Option<u64>
Returns the op_id of the highest-priority OpStatus::Ready operation.
Ties in priority are broken by the lowest op_id (FIFO within priority).
Returns None if no operations are currently in Ready state.
Sourcepub fn stats(&self) -> SchedulerStats
pub fn stats(&self) -> SchedulerStats
Returns a snapshot of aggregate scheduler statistics.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TensorOpScheduler
impl RefUnwindSafe for TensorOpScheduler
impl Send for TensorOpScheduler
impl Sync for TensorOpScheduler
impl Unpin for TensorOpScheduler
impl UnsafeUnpin for TensorOpScheduler
impl UnwindSafe for TensorOpScheduler
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more