Struct tract_libcli::annotations::NodeQId
source · Tuple Fields§
§0: TVec<(usize, String)>§1: usizeImplementations§
source§impl NodeQId
impl NodeQId
sourcepub fn model<'a>(&self, model: &'a dyn Model) -> Option<&'a dyn Model>
pub fn model<'a>(&self, model: &'a dyn Model) -> Option<&'a dyn Model>
Examples found in repository?
src/terminal.rs (line 350)
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
pub fn render_summaries(
model: &dyn Model,
annotations: &Annotations,
options: &DisplayParams,
) -> TractResult<()> {
let total = annotations.tags.values().sum::<NodeTags>();
if options.cost {
println!("{}", White.bold().paint("Cost summary"));
for (c, i) in &total.cost {
println!(" * {:?}: {}", c, render_tdim(i));
}
}
if options.profile {
let summary = annotations.profile_summary.as_ref().unwrap();
println!("{}", White.bold().paint("Most time consuming operations"));
for (op, (dur, n)) in annotations
.tags
.iter()
.map(|(k, v)| {
(k.model(model).unwrap().node_op_name(k.1), v.profile.unwrap_or_default())
})
.sorted_by_key(|a| a.0.to_string())
.group_by(|(n, _)| n.clone())
.into_iter()
.map(|(a, group)| {
(
a,
group
.into_iter()
.fold((Duration::default(), 0), |acc, d| (acc.0 + d.1, acc.1 + 1)),
)
})
.into_iter()
.sorted_by_key(|(_, d)| d.0)
.rev()
{
println!(
" * {} {:3} nodes: {}",
Blue.bold().paint(format!("{:20}", op)),
n,
dur_avg_ratio(dur, summary.sum)
);
}
println!("{}", White.bold().paint("By prefix"));
fn prefixes_for(s: &str) -> impl Iterator<Item = String> + '_ {
use tract_itertools::*;
let split = s.split('.').count();
(0..split).map(move |n| s.split('.').take(n).join("."))
}
let all_prefixes = annotations
.tags
.keys()
.flat_map(|id| prefixes_for(id.model(model).unwrap().node_name(id.1)))
.filter(|s| !s.is_empty())
.sorted()
.unique()
.collect::<Vec<String>>();
for prefix in &all_prefixes {
let sum = annotations
.tags
.iter()
.filter(|(k, _v)| k.model(model).unwrap().node_name(k.1).starts_with(prefix))
.map(|(_k, v)| v)
.sum::<NodeTags>();
if sum.profile.unwrap_or_default().as_secs_f64() / summary.entire.as_secs_f64() < 0.01 {
continue;
}
print!("{} ", dur_avg_ratio(sum.profile.unwrap_or_default(), summary.sum));
for _ in prefix.chars().filter(|c| *c == '.') {
print!(" ");
}
println!("{}", prefix);
}
println!(
"Not accounted by ops: {}",
dur_avg_ratio(summary.entire - summary.sum.min(summary.entire), summary.entire)
);
println!("Entire network performance: {}", dur_avg(summary.entire));
}
Ok(())
}Trait Implementations§
source§impl PartialEq<NodeQId> for NodeQId
impl PartialEq<NodeQId> for NodeQId
impl Eq for NodeQId
impl StructuralEq for NodeQId
impl StructuralPartialEq for NodeQId
Auto Trait Implementations§
impl RefUnwindSafe for NodeQId
impl Send for NodeQId
impl Sync for NodeQId
impl Unpin for NodeQId
impl UnwindSafe for NodeQId
Blanket Implementations§
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.