def CastingNumExprTemplate (func_compare, casting_map = {}, gid2epsilons = {}): # generate the casting num. expr. cnum_expr = None for p,c in casting_map.items(): assert(len(p) == 2) assert((type(p[0]) is int) and (type(p[1]) is int)) gid_from = p[0] gid_to = p[1] assert(gid_to != tft_expr.PRESERVED_CONST_GID) if (gid_from == tft_expr.PRESERVED_CONST_GID): continue assert(0 <= gid_from) assert(gid_from in gid2epsilons.keys()) assert(0 <= gid_to) assert(gid_to in gid2epsilons.keys()) epss_from = gid2epsilons[gid_from] epss_to = gid2epsilons[gid_to] this_expr = None for f in range(0, len(epss_from)): sum_expr = None var_from = GroupErrorVar(gid_from, f) for t in range(0, len(epss_to)): if (func_compare(epss_from[f], epss_to[t])): tc_expr = None if (tft_utils.LINEAR_TYPE_CASTING_CONSTRAINTS): tc_expr = TCastErrorVar(gid_from, f, gid_to, t) else: tc_expr = IR.BE("*", -1, var_from, GroupErrorVar(gid_to, t), True) if (sum_expr is None): sum_expr = tc_expr else: sum_expr = IR.BE("+", -1, sum_expr, tc_expr, True) if (sum_expr is None): continue if (this_expr is None): this_expr = sum_expr else: this_expr = IR.BE("+", -1, this_expr, sum_expr, True) if (this_expr is None): continue this_expr = IR.BE("*", -1, tft_expr.ConstantExpr(c), this_expr, True) if (cnum_expr is None): cnum_expr = this_expr else: cnum_expr = IR.BE("+", -1, cnum_expr, this_expr, True) return cnum_expr
def tcastExpr (self, select, cselect): if (tft_utils.LINEAR_TYPE_CASTING_CONSTRAINTS): return TCastErrorVar(self.gid, select, self.context_gid, cselect) else: return IR.BE("*", -1, GroupErrorVar(self.gid, select), GroupErrorVar(self.context_gid, cselect), True)
def CastingNumExpr (casting_map = {}, gid2epsilons = {}): expr_h2l = CastingNumExprH2L(casting_map, gid2epsilons) expr_l2h = CastingNumExprL2H(casting_map, gid2epsilons) if ((expr_h2l is None) and (expr_l2h is None)): return None if (expr_h2l is None): return expr_l2h if (expr_l2h is None): return expr_h2l return IR.BE("+", -1, expr_h2l, expr_l2h, True)
import tft_ir_api as IR gid = 0 x = IR.RealVE("x", gid, 0.01, 100.0) gid += 1 y = IR.RealVE("y", gid, 0.01, 100.0) gid += 1 x2 = IR.BE("*", gid, x, x) gid += 1 y2 = IR.BE("*", gid, y, y) gid += 1 x2y2 = IR.BE("+", gid, x2, y2) gid += 1 sqrt_x2y2 = IR.UE("sqrt", gid, x2y2) gid += 1 sqrt_x = IR.BE("+", gid, sqrt_x2y2, x) gid += 1 two_sqrt_x = IR.BE("*", gid, IR.FConst(2.0), sqrt_x) gid += 1 sqrt_all = IR.UE("sqrt", gid, two_sqrt_x) gid += 1
import tft_ir_api as IR gid = 0 x = IR.RealVE('x', gid, -10.0, 10.0) e = IR.RealVE('e', gid + 1, -0.000001, 0.000001) gid += 2 temp0 = IR.BE('+', gid, x, e) temp1 = IR.UE('cos', gid + 1, temp0) rel = IR.BE('-', gid + 3, temp1, IR.UE('cos', gid + 2, x)) IR.TuneExpr(rel)
import tft_ir_api as IR var_v = IR.RealVE("v", 0, (-4.5 - 0.0000001), (-0.3 + 0.0000001)) var_w = IR.RealVE("w", 1, (0.4 - 0.000000000001), (0.9 + 0.000000000001)) var_r = IR.RealVE("r", 2, (3.8 - 0.00000001), (7.8 + 0.00000001)) sub_1v = IR.BE("-", 3, IR.FConst(1.0), var_v) sub_ww = IR.BE("*", 4, var_w, var_w) sub_rr = IR.BE("*", 5, var_r, var_r) sub_2v = IR.BE("*", 6, IR.FConst(2.0), var_v) sub_wwrr = IR.BE("*", 7, sub_ww, sub_rr) sub_wwrr1v = IR.BE("/", 8, sub_wwrr, sub_1v) sub_2rr = IR.BE("/", 9, IR.FConst(2.0), sub_rr) r1_sub0 = IR.BE( "*", 12, IR.BE("*", 11, IR.FConst(0.125), IR.BE("-", 10, IR.FConst(3.0), sub_2v)), sub_wwrr1v) r1 = IR.BE("-", 15, IR.BE("-", 14, IR.BE("+", 13, IR.FConst(3.0), sub_2rr), r1_sub0), IR.FConst(4.5)) rs = r1
import math import tft_ir_api as IR gid_data = 0 gid_data_ave = gid_data gid_data_dev = gid_data gid_data_x = gid_data ave = IR.RealVE("ave", gid_data_ave, -1.0, 1.0) dev = IR.RealVE("dev", gid_data_dev, 1.0, 3.0) x = IR.RealVE("x", gid_data_x, -10.0, 10.0) sqrt_2pi = IR.FConst(math.sqrt(2.0 * math.pi)) temp3 = IR.BE("*", 3, dev, sqrt_2pi) a = IR.BE("/", 4, IR.FConst(1.0), temp3) b = ave c = dev temp5 = IR.BE("-", 5, x, b) temp6 = IR.BE("*", 6, temp5, temp5) temp7 = IR.BE("*", 7, IR.FConst(2.0), IR.BE("*", 7, c, c)) temp8 = IR.UE("-", 8, IR.BE("/", 8, temp6, temp7)) temp9 = IR.UE("exp", 9, temp8) rel = IR.BE("*", 10, a, temp9)
b = list() for i in range(n): b.append(IR.RealVE("b{}".format(i), 1, low, high)) x = list() for i in range(n): x.append(IR.FConst(1.0)) g = 2 #j k = 0 #j while convergence not reached: # while loop for k in range(unrolls): # replacement for while loop for i in range(n): # i loop sigma = IR.FConst(0.0) for j in range(n): # j loop if j != i: sigma = IR.BE("+", g, sigma, IR.BE("*", g, A[i][j], x[j])) g += 1 # end j loop x[i] = IR.BE("/", g, IR.BE("-", g, b[i], sigma), A[i][j]) g += 1 # end i loop #j check convergence #j k = k+1 # end while loop print(x[0]) rs = x[0] IR.TuneExpr(rs)
import tft_ir_api as IR gid = 0 a = IR.RealVE('a', gid, -1.0, 1.0) b = IR.RealVE('b', gid + 1, -1.0, 1.0) gid += 2 rel = IR.BE('/', gid + 2, IR.BE('+', gid, a, b), IR.BE('*', gid + 1, a, b)) gid += 3 IR.TuneExpr(rel)
import tft_ir_api as IR x = IR.RealVE("x", 0, -1.57079632679, 1.57079632679) x2 = IR.BE("*", 1, x, x) x3 = IR.BE("*", 2, x2, x) rel = None x5 = IR.BE("*", 3, x2, x3) x7 = IR.BE("*", 4, x2, x5) rel_1 = IR.BE("/", 5, x3, IR.FConst(6.0)) rel_2 = IR.BE("/", 6, x5, IR.FConst(120.0)) rel_3 = IR.BE("/", 7, x7, IR.FConst(5040.0)) rel = IR.BE("-", 10, IR.BE("+", 9, IR.BE("-", 8, x, rel_1), rel_2), rel_3) IR.TuneExpr(rel) IR.ToFPCore(rel, "sine.fpcore")
import tft_ir_api as IR var_v = IR.RealVE("v", 0, (-4.5 - 0.0000001), (-0.3 + 0.0000001)) var_w = IR.RealVE("w", 1, (0.4 - 0.000000000001), (0.9 + 0.000000000001)) var_r = IR.RealVE("r", 2, (3.8 - 0.00000001), (7.8 + 0.00000001)) sub_1v = IR.BE("-", 3, IR.FConst(1.0), var_v) sub_ww = IR.BE("*", 4, var_w, var_w) sub_rr = IR.BE("*", 5, var_r, var_r) sub_2v = IR.BE("*", 6, IR.FConst(2.0), var_v) sub_wwrr = IR.BE("*", 7, sub_ww, sub_rr) sub_wwrr1v = IR.BE("/", 8, sub_wwrr, sub_1v) sub_2rr = IR.BE("/", 9, IR.FConst(2.0), sub_rr) r3_sub0 = IR.BE("*", 23, IR.BE("*", 22, IR.FConst(0.125), IR.BE("+", 21, IR.FConst(1.0), sub_2v)), sub_wwrr1v) r3 = IR.BE("-", 26, IR.BE("-", 25, IR.BE("-", 24, IR.FConst(3.0), sub_2rr),
alen = 16 vlb = -1.0 vub = 1.0 gid_data = 0 assert (alen > 0) assert (vlb < vub) assert (math.log(alen, 2) == int(math.log(alen, 2))) n_stages = int(math.log(alen, 2)) arr = [IR.RealVE("v" + str(i), gid_data, vlb, vub) for i in range(0, alen)] for i_stage in range(1, (n_stages + 1)): l_arr = len(arr) assert (l_arr % 2 == 0) l_arr = int(l_arr / 2) for i in range(0, l_arr): arr[i] = IR.BE("+", i_stage, arr[i], arr[i + l_arr]) arr = arr[0:l_arr] assert (len(arr) == 1) IR.SetGroupWeight(gid_data, 16.0) IR.TuneExpr(arr[0])
import tft_ir_api as IR const_r = IR.FConst(4.0) const_k = IR.FConst(1.11) var_x = IR.RealVE("x", 0, 0.1, 0.3) temp0 = IR.BE("*", 2, IR.BE("*", 1, const_r, var_x), var_x) temp1 = IR.BE("/", 3, var_x, const_k) temp2 = IR.BE("+", 4, temp1, temp1) temp3 = IR.BE("+", 5, IR.FConst(1.0), temp2) rel = IR.BE("/", 6, temp0, temp3) IR.TuneExpr(rel)
import tft_ir_api as IR x = IR.RealVE("x", 0, -2.0, 2.0) x2 = IR.BE("*", 1, x, x) x3 = IR.BE("*", 2, x2, x) rel = None rel_1 = IR.BE("*", 20, IR.FConst(0.954929658551372), x) rel_2 = IR.BE("*", 21, IR.FConst(0.12900613773279798), x3) rel = IR.BE("-", 22, rel_1, rel_2) IR.TuneExpr(rel) IR.ToFPCore(rel, "sineOrder3.fpcore")
import tft_ir_api as IR gid = 0 x = IR.RealVE('x', gid , -10.0, 10.0) e = IR.RealVE('e', gid+1, -0.000001, 0.000001) gid += 2 temp0 = IR.UE('sin', gid+1, IR.BE('/', gid, e, IR.FConst(2.0))) gid += 2 temp1 = IR.BE('/', gid+2, IR.BE('+', gid+1, x, IR.BE('+', gid, x, e)), IR.FConst(2.0)) gid += 3 rel = IR.BE('*', gid+2, IR.FConst(-2.0), IR.BE('*', gid+1, temp0, IR.UE('sin', gid, temp1))) gid += 3 IR.TuneExpr(rel)
import tft_ir_api as IR delta = 1e-08 var_x1 = IR.RealVE("x1", 0, (-15.0 - delta), (15.0 + delta)) var_x2 = IR.RealVE("x2", 1, (-15.0 - delta), (15.0 + delta)) var_x3 = IR.RealVE("x3", 2, (-15.0 - delta), (15.0 + delta)) sub_x1x2 = IR.BE("*", 3, var_x1, var_x2) sub_x1x2x3 = IR.BE("*", 4, sub_x1x2, var_x3) sub_x3x3 = IR.BE("*", 6, var_x3, var_x3) r2_sub0 = IR.BE("*", 12, IR.FConst(2.0), sub_x1x2x3) r2_sub1 = IR.BE("*", 13, IR.FConst(3.0), sub_x3x3) r2_sub2 = IR.BE("*", 14, var_x2, sub_x1x2x3) r2 = IR.BE( "-", 18, IR.BE("+", 17, IR.BE("-", 16, IR.BE("+", 15, r2_sub0, r2_sub1), r2_sub2), r2_sub1), var_x2) rs = r2 IR.TuneExpr(rs)
import tft_ir_api as IR var_T = IR.RealVE("T", 0, float(300.0) - float(0.01), float(300.0) + float(0.01)) var_a = IR.RealVE("a", 1, float(0.401) - float(1e-06), float(0.401) + float(1e-06)) var_b = IR.RealVE("b", 2, float(42.7e-06) - float(1e-10), float(42.7e-06) + float(1e-10)) var_N = IR.RealVE("N", 3, float(995.0), float(1005.0)) var_p = IR.FConst(float(3.5e7)) var_V = IR.RealVE("V", 4, float(0.1) - float(0.005), float(0.5) + float(0.005)) const_k = IR.FConst(float(1.3806503e-23)) temp0 = IR.BE("/", 5, var_N, var_V) sub0 = IR.BE("*", 6, temp0, temp0) sub1 = IR.BE("-", 7, var_V, IR.BE("*", 8, var_N, var_b)) sub2 = IR.BE("*", 9, IR.BE("+", 10, var_p, IR.BE("*", 11, var_a, sub0)), sub1) sub3 = IR.BE("*", 12, IR.BE("*", 13, const_k, var_N), var_T) rel = IR.BE("-", 14, sub2, sub3) IR.TuneExpr(rel) IR.ToFPCore(rel, "carbonGas.fpcore")
import tft_ir_api as IR gid = 0 x = IR.RealVE('x', gid, -1.0, 1.0) gid += 1 temp0 = IR.UE('log', gid + 1, IR.BE('-', gid, IR.FConst(1.0), x)) temp1 = IR.UE('log', gid + 3, IR.BE('+', gid + 2, IR.FConst(1.0), x)) gid += 4 rel = IR.BE('/', gid, temp0, temp1) gid += 1 IR.TuneExpr(rel)
import tft_ir_api as IR gid = 0 x = IR.RealVE('x', gid, -1.0, 1.0) gid += 1 temp0 = IR.BE('+', gid , IR.FConst(1.0), x) # (+ 1.0 x) temp1 = IR.BE('*', gid+1, x, x) # (sqr x) temp2 = IR.BE('*', gid+2, IR.FConst(0.5), temp1) # (* 0.5 (sqr x)) temp3 = IR.BE('+', gid+3, temp2, temp0) gid += 4 rel = IR.BE('*', gid, IR.FConst(-1.0), temp3) gid += 1 IR.TuneExpr(rel)
import tft_ir_api as IR var_u = IR.RealVE("u", 0, (-100.0 - 0.0000001), (100.0 + 0.0000001)) var_v = IR.RealVE("v", 1, (20.0 - 0.000000001), (20000.0 + 0.000000001)) var_T = IR.RealVE("T", 2, (-30.0 - 0.000001), (50.0 + 0.000001)) t1 = IR.BE("+", 4, IR.FConst(331.4), IR.BE("*", 3, IR.FConst(0.6), var_T)) temp = IR.BE("+", 5, t1, var_u) temp = IR.BE("*", 8, temp, temp) r = IR.BE("/", 9, IR.BE("*", 7, IR.UE("-", 6, t1), var_v), temp) IR.TuneExpr(r)
import tft_ir_api as IR A = IR.RealVE("A", 0, 0.0, 100.0) B = IR.RealVE("B", 1, 0.0, 100.0) C = IR.RealVE("C", 2, 0.0, 100.0) rel = IR.BE("*", 4, IR.BE("+", 3, A, B), C) IR.TuneExpr(rel)
def errorExpr (self, scaling_expr, gid2epsilons={}, casting_map={}): assert(isinstance(scaling_expr, tft_expr.ConstantExpr)) assert(type(self.context_gid) is int) assert(type(self.gid) is int) assert(self.context_gid in gid2epsilons.keys()) assert(self.gid in gid2epsilons.keys()) assert((self.gid == self.context_gid) or ((self.gid, self.context_gid) in casting_map.keys())) temp_epss = gid2epsilons[self.gid] temp_context_epss = gid2epsilons[self.context_gid] epss = [] context_epss = [] checkValidEpsilonList(temp_epss) checkValidEpsilonList(temp_context_epss) # scaling up the epsilons for i in range(0, len(temp_epss)): epss.append( tft_expr.ConstantExpr(temp_epss[i].value() * scaling_expr.value()) ) for j in range(0, len(temp_context_epss)): context_epss.append( tft_expr.ConstantExpr(temp_context_epss[j].value() * scaling_expr.value()) ) error_expr = None if (not self.is_precise_opt): error_expr = IR.BE("*", -1, GroupErrorVar(self.gid, 0), epss[0], True) for i in range(1, len(epss)): error_expr = IR.BE("+", -1, error_expr, IR.BE("*", -1, GroupErrorVar(self.gid, i), epss[i], True), True) tc_error = None if (self.gid != self.context_gid): for i in range(0, len(epss)): for j in range(0, len(context_epss)): if (epss[i] < context_epss[j]): temp_error = self.tcastExpr(i, j) temp_error = IR.BE("*", -1, temp_error, context_epss[j], # tft_expr.ConstantExpr(context_epss[j].value() + # (context_epss[j].value() * epss[i].value())), True) if (tc_error is None): tc_error = temp_error else: tc_error = IR.BE("+", -1, tc_error, temp_error, True) if (error_expr is None and tc_error is None): return tft_expr.ConstantExpr(0.0) elif (tc_error is None): return error_expr elif (error_expr is None): return tc_error else: return IR.BE("+", -1, error_expr, tc_error, True)
import tft_ir_api as IR const_r = IR.FConst(4.0) const_k = IR.FConst(1.11) var_x = IR.RealVE("x", 0, (0.1 - 1e-06), (0.3 + 1e-06)) temp0 = IR.BE("*", 1, const_r, var_x) temp1 = IR.BE("/", 2, var_x, const_k) temp2 = IR.BE("+", 3, IR.FConst(1.0), temp1) rel = IR.BE("/", 4, temp0, temp2) IR.TuneExpr(rel)
def scoreExpr (self): global EPS_SCORE ret_se = None if (len(IR.PREC_CANDIDATES) == 2): for gid,c in self.gid_counts.items(): if (gid == tft_expr.PRESERVED_CONST_GID): continue checkValidEpsilonList(self.gid2epsilons[gid]) group_evar = None assert(tft_utils.OPT_METHOD in tft_utils.OPT_METHODS) if (tft_utils.OPT_METHOD == "max-benefit"): group_evar = GroupErrorVar(gid, 0) elif (tft_utils.OPT_METHOD == "min-penalty"): group_evar = GroupErrorVar(gid, 1) else: assert(False), "No such optimization method: " + str(tft_utils.OPT_METHOD) assert(group_evar is not None) expr_score = IR.BE("*", -1, group_evar, tft_expr.ConstantExpr(int(c)), True) assert(group_evar.hasBounds()) if gid in self.gid_weight.keys(): weight = self.gid_weight[gid] assert((type(weight) is float) and (0 <= weight)) expr_score = IR.BE("*", -1, expr_score, tft_expr.ConstantExpr(weight), True) if (ret_se is None): ret_se = expr_score else: ret_se = IR.BE("+", -1, ret_se, expr_score, True) assert(ret_se is not None) return ret_se elif (len(IR.PREC_CANDIDATES) >= 3): assert(tft_utils.OPT_METHOD in tft_utils.OPT_METHODS) if (tft_utils.OPT_METHOD == "max-benefit"): EPS_SCORE[tft_alloc.EPSILON_32] = 100.0 EPS_SCORE[tft_alloc.EPSILON_64] = 1.0 EPS_SCORE[tft_alloc.EPSILON_128] = 0.0 elif (tft_utils.OPT_METHOD == "min-penalty"): EPS_SCORE[tft_alloc.EPSILON_32] = 0.0 EPS_SCORE[tft_alloc.EPSILON_64] = 1.0 EPS_SCORE[tft_alloc.EPSILON_128] = 100.0 else: assert(False), "No such optimization method: " + str(tft_utils.OPT_METHOD) for gid,c in self.gid_counts.items(): if (gid == tft_expr.PRESERVED_CONST_GID): continue checkValidEpsilonList(self.gid2epsilons[gid]) for ei in range(0, len(self.gid2epsilons[gid])): expr_score = None group_evar = GroupErrorVar(gid, ei) assert(group_evar.hasBounds()) eps = self.gid2epsilons[gid][ei].value() assert(eps in EPS_SCORE.keys()) weight = EPS_SCORE[eps] assert(type(weight) is float) weight = weight * float(c) if gid in self.gid_weight.keys(): ext_weight = self.gid_weight[gid] assert((type(ext_weight) is float) and (0 <= ext_weight)) weight = weight * ext_weight assert(0 <= weight) if (weight > 0.0): expr_score = IR.BE("*", -1, group_evar, tft_expr.ConstantExpr(weight), True) if (ret_se is None): ret_se = expr_score else: ret_se = IR.BE("+", -1, ret_se, expr_score, True) else: pass assert(ret_se is not None) return ret_se else: sys.exit("Error: invalid # of bit-width candidates...")
import tft_ir_api as IR A = IR.RealVE("A", 0, 0.0, 100.0) rel = IR.BE("+", 4, A, A) IR.TuneExpr(rel)
# ======== # sin(A/2) = +/- \sqrt{\frac{1 - cos(A)}{2.0}} # ======== import math import tft_ir_api as IR x = IR.RealVE("x", 0, 0.0, 20.0) a = IR.RealVE("a", 0, 1.0, 5.0) x2 = IR.BE("*", 1, x, x) a2 = IR.BE("*", 2, a, a) a3 = IR.BE("*", 3, a, a2) e_0 = IR.BE("*", 4, IR.FConst(-1.0), x2) e_1 = IR.BE("*", 5, IR.FConst(2.0), a2) e_2 = IR.BE("/", 6, e_0, e_1) e = IR.UE("exp", 7, e_2) d_0 = IR.BE("*", 8, x2, e) d = IR.BE("/", 9, d_0, a3) rel = IR.BE("*", 10, IR.FConst(math.sqrt(2.0 / math.pi)), d) IR.SetGroupWeight(7, 100.0) IR.TuneExpr(rel)
def errorExpr (self, context_gid, gid): assert(False) assert(type(context_gid) is int) assert(type(gid) is int) assert(context_gid in self.gid2epsilons.keys()) assert(gid in self.gid2epsilons.keys()) assert((gid == context_gid) or ((gid, context_gid) in self.casting_map.keys())) temp_epss = self.gid2epsilons[gid] temp_context_epss = self.gid2epsilons[context_gid] epss = [] context_epss = [] checkValidEpsilonList(temp_epss) checkValidEpsilonList(temp_context_epss) # scaling up the epsilons scaling_expr = self.scalingUpFactor() for i in range(0, len(temp_epss)): epss.append( tft_expr.ConstantExpr(temp_epss[i].value() * scaling_expr.value()) ) for j in range(0, len(temp_context_epss)): context_epss.append( tft_expr.ConstantExpr(temp_context_epss[j].value() * scaling_expr.value()) ) error_expr = IR.BE("*", -1, GroupErrorVar(gid, 0), epss[0], True) for i in range(1, len(epss)): error_expr = IR.BE("+", -1, error_expr, IR.BE("*", -1, GroupErrorVar(gid, i), epss[i], True), True) tc_error = None if (gid != context_gid): for i in range(0, len(epss)): for j in range(0, len(context_epss)): if (epss[i] < context_epss[j]): temp_error = IR.BE("*", -1, GroupErrorVar(gid, i), GroupErrorVar(context_gid, j), True) temp_error = IR.BE("*", -1, temp_error, context_epss[j], # tft_expr.ConstantExpr(context_epss[j].value() + # (context_epss[j].value() * epss[i].value())), True) if (tc_error is None): tc_error = temp_error else: tc_error = IR.BE("+", -1, tc_error, temp_error, True) if (tc_error is None): return error_expr else: return IR.BE("+", -1, error_expr, tc_error, True)
import tft_ir_api as IR var_x1 = IR.RealVE("x1", 0, -5.0, 5.0) var_x2 = IR.RealVE("x2", 1, -20.0, 5.0) temp0 = IR.BE("*", 2, var_x1, var_x1) # x1^2 temp1 = IR.BE("*", 3, temp0, var_x1) # x1^3 sub2_0 = IR.BE( "-", 4, IR.BE("+", 5, IR.BE("*", 6, IR.FConst(3.0), temp0), IR.BE("*", 7, IR.FConst(2.0), var_x2)), var_x1) sub2_1 = IR.BE("+", 8, temp0, IR.FConst(1.0)) sub2 = IR.BE("/", 9, sub2_0, sub2_1) sub3_0_0_0 = IR.BE("*", 10, IR.BE("*", 11, IR.FConst(2.0), var_x1), sub2) sub3_0_0_1 = IR.BE("-", 12, sub2, IR.FConst(3.0)) sub3_0_0 = IR.BE("*", 13, sub3_0_0_0, sub3_0_0_1) sub3_0_1 = IR.BE( "*", 14, temp0, IR.BE("-", 15, IR.BE("*", 16, IR.FConst(4.0), sub2), IR.FConst(6.0))) sub3_0 = IR.BE("+", 17, sub3_0_0, sub3_0_1) sub3_1 = IR.BE("+", 18, temp0, IR.FConst(1.0)) sub3 = IR.BE("*", 19, sub3_0, sub3_1) rel_temp0 = IR.BE( "+", 20, IR.BE( "+", 21, IR.BE("+", 22, sub3, IR.BE("*", 23, IR.BE("*", 24, IR.FConst(3.0), temp0), sub2)),
import tft_ir_api as IR x = IR.RealVE("x", 0, 0.0, 1.0) x2 = IR.BE("*", 1, x, x) x3 = IR.BE("*", 2, x2, x) rel = None x4 = IR.BE("*", 11, x2, x2) rel_1 = IR.BE("*", 12, IR.FConst(0.5), x) rel_2 = IR.BE("*", 13, IR.FConst(0.125), x2) rel_3 = IR.BE("*", 14, IR.FConst(0.0625), x3) rel_4 = IR.BE("*", 15, IR.FConst(0.0390625), x4) rel = IR.BE( "-", 19, IR.BE("+", 18, IR.BE("-", 17, IR.BE("+", 16, IR.FConst(1.0), rel_1), rel_2), rel_3), rel_4) IR.TuneExpr(rel) IR.ToFPCore(rel, "sqroot.fpcore")
import tft_ir_api as IR var_v = IR.RealVE("v", 0, (-4.5 - 0.0000001), (-0.3 + 0.0000001)) var_w = IR.RealVE("w", 1, (0.4 - 0.000000000001), (0.9 + 0.000000000001)) var_r = IR.RealVE("r", 2, (3.8 - 0.00000001), (7.8 + 0.00000001)) sub_1v = IR.BE("-", 3, IR.FConst(1.0), var_v) sub_ww = IR.BE("*", 4, var_w, var_w) sub_rr = IR.BE("*", 5, var_r, var_r) sub_wwrr = IR.BE("*", 7, sub_ww, sub_rr) sub_wwrr1v = IR.BE("/", 8, sub_wwrr, sub_1v) r2_sub0 = IR.BE("*", 16, IR.FConst(6.0), var_v) r2_sub1 = IR.BE("*", 18, IR.BE("*", 17, IR.FConst(0.5), var_v), sub_wwrr1v) r2 = IR.BE("-", 20, IR.BE("-", 19, r2_sub0, r2_sub1), IR.FConst(2.5)) rs = r2 IR.TuneExpr(rs)