Last active
March 7, 2025 12:09
-
-
Save panther03/4c34cdacfbcd3073b2193d37870ac666 to your computer and use it in GitHub Desktop.
esyn patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/abc/src/aig/gia/gia.h b/abc/src/aig/gia/gia.h | |
index d3eadfb..cd2dcc6 100644 | |
--- a/abc/src/aig/gia/gia.h | |
+++ b/abc/src/aig/gia/gia.h | |
@@ -495,7 +495,7 @@ static inline int Gia_ObjIsCi( Gia_Obj_t * pObj ) { | |
static inline int Gia_ObjIsCo( Gia_Obj_t * pObj ) { return pObj->fTerm && pObj->iDiff0 != GIA_NONE; } | |
static inline int Gia_ObjIsAnd( Gia_Obj_t * pObj ) { return!pObj->fTerm && pObj->iDiff0 != GIA_NONE; } | |
static inline int Gia_ObjIsXor( Gia_Obj_t * pObj ) { return Gia_ObjIsAnd(pObj) && pObj->iDiff0 < pObj->iDiff1; } | |
-static inline int Gia_MuxIObjIsd( Gia_Man_t * p, int iObj ) { return p->pMuxes && p->pMuxes[iObj] > 0; } | |
+static inline int Gia_ObjIsMuxId( Gia_Man_t * p, int iObj ) { return p->pMuxes && p->pMuxes[iObj] > 0; } | |
static inline int Gia_ObjIsMux( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjIsMuxId( p, Gia_ObjId(p, pObj) ); } | |
static inline int Gia_ObjIsAndReal( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjIsAnd(pObj) && pObj->iDiff0 > pObj->iDiff1 && !Gia_ObjIsMux(p, pObj); } | |
static inline int Gia_ObjIsBuf( Gia_Obj_t * pObj ) { return pObj->iDiff0 == pObj->iDiff1 && pObj->iDiff0 != GIA_NONE && !pObj->fTerm; } | |
diff --git a/e-rewriter/src/main.rs b/e-rewriter/src/main.rs | |
index bba6b4f..7677950 100644 | |
--- a/e-rewriter/src/main.rs | |
+++ b/e-rewriter/src/main.rs | |
@@ -55,6 +55,7 @@ fn main() ->Result<(), Box<dyn std::error::Error>> { | |
//let mut unique_solutions = HashSet::new(); | |
// runner.egraph.dot().to_png("/data/cchen/E-Brush/image/process.png").unwrap(); | |
let mut results: BTreeMap<i32, RecExpr<Prop>> = BTreeMap::new(); | |
+ let mut results_names: BTreeMap<i32, &str> = BTreeMap::new(); | |
let mut res_cost: HashMap<i32, usize> = HashMap::new(); | |
let mut sym_cost_dict: BTreeMap<i32, f64> = BTreeMap::new(); | |
@@ -70,7 +71,9 @@ fn main() ->Result<(), Box<dyn std::error::Error>> { | |
let (best_cost_base_1,best_base_1 )=extractor_base_1.find_best(root); | |
results.insert(0, best_base_0.clone()); | |
+ results_names.insert(0, "AstSize"); | |
results.insert(1, best_base_1.clone()); | |
+ results_names.insert(1, "AstDepth"); | |
// let (sym_cost0,input_para0) =xgboost(&(best_base_0.to_string())); | |
// sym_cost_dict.insert(0,sym_cost0); | |
@@ -159,7 +162,7 @@ fn main() ->Result<(), Box<dyn std::error::Error>> { | |
}); | |
- | |
+/* | |
let num = iterations * 6 + 2; | |
let output_cmd = Command::new("python") | |
.arg("graph_info.py") | |
@@ -198,7 +201,7 @@ fn main() ->Result<(), Box<dyn std::error::Error>> { | |
// println!("Key: {}, RecExpr: {:?}", key, rec_expr); | |
} | |
- | |
+ */ | |
@@ -283,11 +286,13 @@ fn main() ->Result<(), Box<dyn std::error::Error>> { | |
let mut count = 0; | |
let output_directory = "test_data_beta_runner/"; | |
+ let mut results_names_out = File::create("results_names.txt").unwrap(); | |
for min_key in min_keys.iter() { | |
let output = results | |
.get(min_key) | |
.map(|result| result.to_string()) | |
.unwrap_or_default(); | |
+ results_names_out.write(format!("{}|{}\n", *min_key,results_names.get(min_key).unwrap_or(&"unknown")).as_bytes())?; | |
let output_file_name = format!("output_from_egg{}.txt", count); | |
let output_file_path = Path::new(output_directory).join(output_file_name); | |
if let Ok(mut output_file) = File::create(output_file_path) { | |
@@ -315,4 +320,4 @@ fn main() ->Result<(), Box<dyn std::error::Error>> { | |
count += 1; | |
} | |
Ok(()) | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/e-rewriter/src/utils/cost.rs b/e-rewriter/src/utils/cost.rs | |
index 8cabed2..6fa2309 100644 | |
--- a/e-rewriter/src/utils/cost.rs | |
+++ b/e-rewriter/src/utils/cost.rs | |
@@ -105,4 +105,27 @@ impl<L: Language> CostFunction<L> for AstDepth { | |
{ | |
1 + enode.fold(0, |max, id| max.max(costs(id))) // 将常量改为浮点数 | |
} | |
+} | |
+ | |
+ | |
+pub struct AstDepth2; | |
+impl CostFunction<Prop> for AstDepth2 { | |
+ type Cost = usize; // 将类型改为 f64 | |
+ fn cost<C>(&mut self, enode: &Prop, mut costs: C) -> Self::Cost | |
+ where | |
+ C: FnMut(Id) -> Self::Cost, | |
+ { | |
+ /*(match enode { | |
+ &Prop::And(_) => 1, | |
+ _ => 0 | |
+ })*/ | |
+ let op = enode.to_string(); | |
+ (match op.as_str() { | |
+ "!" => 9 , | |
+ "+" => 26 , | |
+ "*"=> 22 , | |
+ //"&" => 0.0 as f32, | |
+ _=> 0 | |
+ }) + enode.fold(0, |max, id| max.max(costs(id))) // 将常量改为浮点数 | |
+ } | |
} | |
\ No newline at end of file | |
diff --git a/e-rewriter/src/utils/xgboost.rs b/e-rewriter/src/utils/xgboost.rs | |
index 137ac65..f319480 100644 | |
--- a/e-rewriter/src/utils/xgboost.rs | |
+++ b/e-rewriter/src/utils/xgboost.rs | |
@@ -9,7 +9,7 @@ use crate::utils::{sym_eval::*}; | |
pub fn xgboost(input_string: &str) -> (f64, Vec<f32>) { | |
// load model and predict | |
- let bst = Booster::load("/data/cchen/E-Brush/e-rewriter/src/model/xgb_delay.model"); | |
+ let bst = Booster::load("e-rewriter/src/model/xgb_delay.model"); | |
let operator_counts = count_operators(&input_string); | |
let x1 = operator_counts.get("+").copied().unwrap_or(0); | |
@@ -41,7 +41,7 @@ pub fn xgboost(input_string: &str) -> (f64, Vec<f32>) { | |
pub fn xgboost_new(input_string: &str,&graph_density:&f32,&graph_edge:&f32) -> (f64, Vec<f32>) { | |
// load model and predict | |
- let bst = Booster::load("/data/cchen/E-Brush/e-rewriter/src/model/xgb.model"); | |
+ let bst = Booster::load("e-rewriter/src/model/xgb.model"); | |
//let bst = Booster::load("/data/cchen/E-Brush/e-rewriter/src/model/xgb_23_10_26_area.model"); | |
//let bst = Booster::load("/data/cchen/E-Brush/e-rewriter/src/model/xgb_23_10_26_delay.model"); | |
let operator_counts = count_operators(&input_string); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment