torsh_jit/graph/
metadata.rs1use std::collections::HashMap;
4
5#[derive(Debug, Clone, Default)]
7pub struct GraphMetadata {
8 pub name: String,
10
11 pub version: String,
13
14 pub creator: String,
16
17 pub target: Option<String>,
19
20 pub optimization_level: OptimizationLevel,
22
23 pub custom: HashMap<String, String>,
25}
26
27impl GraphMetadata {
28 pub fn new(name: String) -> Self {
30 Self {
31 name,
32 version: "1.0.0".to_string(),
33 creator: "torsh-jit".to_string(),
34 target: None,
35 optimization_level: OptimizationLevel::Default,
36 custom: HashMap::new(),
37 }
38 }
39
40 pub fn with_version(mut self, version: String) -> Self {
42 self.version = version;
43 self
44 }
45
46 pub fn with_creator(mut self, creator: String) -> Self {
48 self.creator = creator;
49 self
50 }
51
52 pub fn with_target(mut self, target: String) -> Self {
54 self.target = Some(target);
55 self
56 }
57
58 pub fn with_optimization_level(mut self, level: OptimizationLevel) -> Self {
60 self.optimization_level = level;
61 self
62 }
63
64 pub fn with_custom(mut self, key: String, value: String) -> Self {
66 self.custom.insert(key, value);
67 self
68 }
69
70 pub fn get_custom(&self, key: &str) -> Option<&String> {
72 self.custom.get(key)
73 }
74}
75
76#[derive(Debug, Clone, PartialEq, Eq)]
78pub enum OptimizationLevel {
79 None, Basic, Default, Aggressive, }
84
85impl Default for OptimizationLevel {
86 fn default() -> Self {
87 OptimizationLevel::Default
88 }
89}