Skip to main content

TraceSession

Struct TraceSession 

Source
pub struct TraceSession { /* private fields */ }
Expand description

Streaming trace session writing TensorFlow-Profiler-style span JSONL.

Implementations§

Source§

impl TraceSession

Source

pub fn open(path: impl AsRef<Path>, run: ProfileRun) -> Result<Self>

Open a trace and own its single root span until Self::finish.

Source

pub fn begin_span( &self, name: impl Into<String>, kind: SpanKind, ) -> SpanGuard<'_>

Begin a nested span; parent is the top of the session span stack (TF Profiler call tree).

Source

pub fn begin_measurement(&self, name: impl Into<String>) -> SpanGuard<'_>

Begin the single caller-controlled region used for total-time comparisons.

Source

pub fn begin_step_span( &self, name: impl Into<String>, step: ExecutionStep, kind: SpanKind, ) -> SpanGuard<'_>

Begin a span tagged with a PyTorch-style training step (forward / backward / optimizer).

Source

pub fn record_completed_host_span( &self, name: impl Into<String>, kind: SpanKind, start_ns: u64, duration_ns: u64, ) -> Result<SpanId>

Record already-completed host work without changing the live span stack.

start_ns is a monotonic offset from this session’s start and duration_ns must be positive. The interval must have completed before this call. The closed span is attached directly to the session root, so it may overlap live nested spans without implying a synchronous parent/child call relationship.

Source

pub fn elapsed_ns(&self) -> u64

Source

pub fn host_timestamp_ns(&self, instant: Instant) -> Result<u64>

Convert an Instant from this process into this trace session’s monotonic nanosecond clock without an independently sampled anchor.

Source

pub fn record_op(&self, span_id: SpanId, op: OpRecord<'_>) -> Result<()>

Record a timed op observation attached to span_id.

Source

pub fn record_tensor( &self, span_id: SpanId, tensor: TensorRecord<'_>, ) -> Result<()>

Record tensor metadata. Logical allocation lifetimes require explicit memory events.

Source

pub fn record_tensor_stats( &self, span_id: &str, label: &str, tensor: &Tensor, ) -> Result<()>

Record device-reduced numerical statistics for a caller-labeled Candle tensor.

Source

pub fn record_memory_alloc( &self, span_id: SpanId, mem: MemoryRecord<'_>, ) -> Result<()>

Record an explicit tensor allocation (TensorFlow memory timeline).

Source

pub fn record_memory_free( &self, span_id: SpanId, mem: MemoryRecord<'_>, ) -> Result<()>

Record an explicit tensor deallocation.

Source

pub fn record_device_memory(&self, sample: DeviceMemoryRecord<'_>) -> Result<()>

Record a device-level memory checkpoint (cudaMemGetInfo-style).

Source

pub fn record_device_interval( &self, span_id: SpanId, interval: DeviceIntervalRecord<'_>, ) -> Result<()>

Source

pub fn record_call_edge( &self, from: SpanId, to: SpanId, duration_ns: u64, ) -> Result<()>

Source

pub fn record_data_edge(&self, from_tensor: &str, to_tensor: &str) -> Result<()>

Source

pub fn record_gradient( &self, root: impl Into<String>, key: impl Into<String>, state: GradientState, norm: Option<f64>, ) -> Result<()>

Record one parameter gradient fact from a probe run.

Present requires a finite positive norm, Zero requires positive zero, and Missing or NonFinite require None. Exact-contract captures emit one event per (root, key).

Source

pub fn flush(&self) -> Result<()>

Source

pub fn finish(self) -> Result<PathBuf>

Close the owned root span, flush, and return the trace path.

Source

pub fn finish_failed(self, reason: impl Into<String>) -> Result<PathBuf>

Finalize a diagnosable partial trace without presenting it as complete evidence.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V