diff options
author | Laurent Mazare <laurent.mazare@gmail.com> | 2024-03-08 15:04:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-08 15:04:18 +0100 |
commit | ea984d04210cf882953d1149a5bbc6b66f4157fb (patch) | |
tree | b6983bd78df16ccec571927b7e868f55cb578201 /candle-core/src/display.rs | |
parent | 96345837817ce407edb8c465ce9fce61bd22d947 (diff) | |
download | candle-ea984d04210cf882953d1149a5bbc6b66f4157fb.tar.gz candle-ea984d04210cf882953d1149a5bbc6b66f4157fb.tar.bz2 candle-ea984d04210cf882953d1149a5bbc6b66f4157fb.zip |
Expose more printer options. (#1817)
Diffstat (limited to 'candle-core/src/display.rs')
-rw-r--r-- | candle-core/src/display.rs | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/candle-core/src/display.rs b/candle-core/src/display.rs index 4f5a390e..7e6e3cf8 100644 --- a/candle-core/src/display.rs +++ b/candle-core/src/display.rs @@ -65,12 +65,13 @@ impl std::fmt::Debug for Tensor { } /// Options for Tensor pretty printing +#[derive(Debug, Clone)] pub struct PrinterOptions { - precision: usize, - threshold: usize, - edge_items: usize, - line_width: usize, - sci_mode: Option<bool>, + pub precision: usize, + pub threshold: usize, + pub edge_items: usize, + pub line_width: usize, + pub sci_mode: Option<bool>, } static PRINT_OPTS: std::sync::Mutex<PrinterOptions> = @@ -89,6 +90,10 @@ impl PrinterOptions { } } +pub fn print_options() -> &'static std::sync::Mutex<PrinterOptions> { + &PRINT_OPTS +} + pub fn set_print_options(options: PrinterOptions) { *PRINT_OPTS.lock().unwrap() = options } @@ -117,6 +122,26 @@ pub fn set_print_options_full() { } } +pub fn set_line_width(line_width: usize) { + PRINT_OPTS.lock().unwrap().line_width = line_width +} + +pub fn set_precision(precision: usize) { + PRINT_OPTS.lock().unwrap().precision = precision +} + +pub fn set_edge_items(edge_items: usize) { + PRINT_OPTS.lock().unwrap().edge_items = edge_items +} + +pub fn set_threshold(threshold: usize) { + PRINT_OPTS.lock().unwrap().threshold = threshold +} + +pub fn set_sci_mode(sci_mode: Option<bool>) { + PRINT_OPTS.lock().unwrap().sci_mode = sci_mode +} + struct FmtSize { current_size: usize, } |