Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/ein16/synth/d2/run.py
ViewVC logotype

Diff of /branches/ein16/synth/d2/run.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4455, Wed Aug 24 23:39:30 2016 UTC revision 4456, Thu Aug 25 04:03:27 2016 UTC
# Line 196  Line 196 
196      return (app, coeffs, dimF, names)      return (app, coeffs, dimF, names)
197    
198  # checks to see if specific ex works  # checks to see if specific ex works
199  def create_embed_app(opr_inner, opr_outer, t_num, fty, title):  def create_embed_app(ex, opr_inner, opr_outer, t_num, fty, title):
200      print "current embed inner: "+opr_inner.name+"("+str(opr_inner.id)+") outer: " +opr_outer.name+"("+str(opr_outer.id)+")#"+str(t_num)      print "current embed inner: "+opr_inner.name+"("+str(opr_inner.id)+") outer: " +opr_outer.name+"("+str(opr_outer.id)+")#"+str(t_num)
201      # current example      # current example
202      (name,opr_inner,ishape)= get_single_example(opr_inner, t_num, args_types)      (name, ishape)= get_single_exampleEx(ex, t_num)
203      # first layer      # first layer
204      # get result after applying operators      # get result after applying operators
205      (tf1, tshape1) = get_tshape(opr_inner,ishape)      (tf1, tshape1) = get_tshape(opr_inner,ishape)
# Line 255  Line 255 
255      return (len(l), l[ex_ty2])      return (len(l), l[ex_ty2])
256    
257    
258  def embed_base_specific_ex(opr_inner, opr_outer, t_num, t_ty2):  def embed_base_specific_ex(ex, opr_inner, opr_outer, t_num, t_ty2):
259      global rst_total      global rst_total
260      rst_total+= 1      rst_total+= 1
261      # get specific outer operator      # get specific outer operator
# Line 271  Line 271 
271      (fty, s) = get_fty(t_ty2)      (fty, s) = get_fty(t_ty2)
272      names="p_aty"+str(args_types)+"_i"+str(opr_inner.id)+"_o"+str(opr_outer.id)+"_n"+str(t_num)+s      names="p_aty"+str(args_types)+"_i"+str(opr_inner.id)+"_o"+str(opr_outer.id)+"_n"+str(t_num)+s
273      print "names",names      print "names",names
274      rtn = create_embed_app(opr_inner, opr_outer, t_num, fty, names)      rtn = create_embed_app(ex, opr_inner, opr_outer, t_num, fty, names)
275      if(rtn==None):      if(rtn==None):
276          print "found none after create embed app"          print "found none after create embed app"
277          return          return
# Line 356  Line 356 
356      writeCumulative()      writeCumulative()
357    
358  ################################################## iterating ###############################################  ################################################## iterating ###############################################
359  def iter_num(opr_inner, opr_outer, n_num, t_ty2):  def iter_num(ex, opr_inner, opr_outer, n_num, t_ty2):
360      print "inside iter num"      print "inside iter num"
361      for t_num  in range(n_num):      for t_num  in range(n_num):
362          embed_base_specific_ex(opr_inner, opr_outer, t_num, t_ty2)          embed_base_specific_ex(ex, opr_inner, opr_outer, t_num, t_ty2)
363    
364  #iterates over extra type and ex_num type  #iterates over extra type and ex_num type
365  def embed_base_iter_ty2(opr_inner, opr_outer):  def embed_base_iter_ty2(ex, opr_inner, opr_outer):
366      print "inside embed base iter -ty 2 "      print "inside embed base iter -ty 2 "
367      ex_outer = oprToEx(opr_inner, args_types)      ex_outer = oprToEx(opr_inner, args_types)
368      n_num = len(ex_outer.tys)      n_num = len(ex_outer.tys)
# Line 372  Line 372 
372    
373          for t_ty2 in range(n_ty2):  #extra type          for t_ty2 in range(n_ty2):  #extra type
374              print "as extra type using ", t_ty2              print "as extra type using ", t_ty2
375              iter_num(opr_inner, opr_outer, n_num, t_ty2)              iter_num(ex, opr_inner, opr_outer, n_num, t_ty2)
376      else:      else:
377           iter_num(opr_inner, opr_outer, n_num,  None)           iter_num(ex, opr_inner, opr_outer, n_num,  None)
378      return      return
379    
380  #iterating ex_outer from 0...l  #iterating ex_outer from 0...l
381  # iterate over outer operator and extra type  # iterate over outer operator and extra type
382  def embed_base_iter_outer2(opr_inner, t_num):  def embed_base_iter_outer2(ex, opr_inner, t_num):
383      # print "\nembed_base_iter_outer: ex_opr",ex_opr      # print "\nembed_base_iter_outer: ex_opr",ex_opr
384      n_outer = getN()      n_outer = getN()
385      #writeall(y)      #writeall(y)
# Line 408  Line 408 
408              # use all field types as extra types              # use all field types as extra types
409              (n_ty2, _) = get_extra(0)              (n_ty2, _) = get_extra(0)
410              for t_ty2 in range(n_ty2):  #extra type              for t_ty2 in range(n_ty2):  #extra type
411                  embed_base_specific_ex(opr_inner, opr_outer, t_num, t_ty2)                  embed_base_specific_ex(ex, opr_inner, opr_outer, t_num, t_ty2)
412          else:          else:
413              embed_base_specific_ex(opr_inner, opr_outer, t_num,  None)              embed_base_specific_ex(ex, opr_inner, opr_outer, t_num,  None)
414              writeResults_outer(opr_inner, opr_outer)              writeResults_outer(opr_inner, opr_outer)
415      return      return
416  def embed_base_iter_ty2_wihty1(opr_inner, opr_outer, t_num):  def embed_base_iter_ty2_wihty1(ex, opr_inner, opr_outer, t_num):
417    
418      ex_outer = oprToEx(opr_inner, args_types)      ex_outer = oprToEx(opr_inner, args_types)
419    
# Line 424  Line 424 
424    
425              print "as extra type using ", t_ty2              print "as extra type using ", t_ty2
426    
427              embed_base_specific_ex(opr_inner, opr_outer, t_num, t_ty2)              embed_base_specific_ex(ex, opr_inner, opr_outer, t_num, t_ty2)
428    
429      else:      else:
430    
431          embed_base_specific_ex(opr_inner, opr_outer, t_num, None)          embed_base_specific_ex(ex, opr_inner, opr_outer, t_num, None)
432    
433      return      return
434    
435  #iterating ex_outer from 0...length(potential outer_operators)  #iterating ex_outer from 0...length(potential outer_operators)
436  def embed_base_iter_outer(opr_inner):  def embed_base_iter_outer(ex, opr_inner):
437      writeTitle_inner(opr_inner)      writeTitle_inner(opr_inner)
438      #have ex_opr iterating over ex_outer      #have ex_opr iterating over ex_outer
439      n_outer = getN()      n_outer = getN()
# Line 457  Line 457 
457          rst_NA = 0          rst_NA = 0
458          opr_outer = id_toOpr(t_outer)          opr_outer = id_toOpr(t_outer)
459          writeTitle_outer(opr_inner, opr_outer)          writeTitle_outer(opr_inner, opr_outer)
460          embed_base_iter_ty2(opr_inner, opr_outer)          embed_base_iter_ty2(ex, opr_inner, opr_outer)
461          writeResults_outer(opr_inner, opr_outer)          writeResults_outer(opr_inner, opr_outer)
462      return      return
463    
# Line 465  Line 465 
465  def embed2_iter_inner():  def embed2_iter_inner():
466      n_opr = getN()      n_opr = getN()
467      for t_opr in range(n_opr):      for t_opr in range(n_opr):
468          embed_base_iter_outer(id_toOpr(t_opr))          opr_inner = (id_toOpr(t_opr))
469            ex = oprToEx(opr_inner, args_types)
470            embed_base_iter_outer(ex, opr_inner)
471      return      return
472    
473    
# Line 492  Line 494 
494          rst_NA = 0          rst_NA = 0
495          opr_inner = id_toOpr(t_opr)          opr_inner = id_toOpr(t_opr)
496          writeTitle_outer(opr_inner, opr_outer)          writeTitle_outer(opr_inner, opr_outer)
497          embed_base_iter_ty2(opr_inner, opr_outer)          ex = oprToEx(opr_inner, args_types)
498            embed_base_iter_ty2(ex, opr_inner, opr_outer)
499          writeResults_outer(opr_inner, opr_outer)          writeResults_outer(opr_inner, opr_outer)
500      return      return
501    
# Line 585  Line 588 
588          # iterate over double layer with unary operator          # iterate over double layer with unary operator
589          t_inner = int(sys.argv[shift+1])          t_inner = int(sys.argv[shift+1])
590          opr_inner = id_toOpr(t_inner)          opr_inner = id_toOpr(t_inner)
591          embed_base_iter_outer(opr_inner)          ex = oprToEx(opr_inner, args_types)
592            embed_base_iter_outer(ex, opr_inner)
593          writeCumulative()          writeCumulative()
594      elif(args==5):      elif(args==5):
595          t_outer = int(sys.argv[shift+1])          t_outer = int(sys.argv[shift+1])
# Line 600  Line 604 
604          opr_inner = id_toOpr(t_inner)          opr_inner = id_toOpr(t_inner)
605          writeTitle_outer(opr_inner, opr_outer)          writeTitle_outer(opr_inner, opr_outer)
606          print "about to call embed base iter ty 2 "          print "about to call embed base iter ty 2 "
607          embed_base_iter_ty2(opr_inner, opr_outer)          ex = oprToEx(opr_inner, args_types)
608            embed_base_iter_ty2(ex, opr_inner, opr_outer)
609          writeResults_outer(opr_inner, opr_outer)          writeResults_outer(opr_inner, opr_outer)
610      elif (args==20):      elif (args==20):
611          t_inner = int(sys.argv[shift+1])          t_inner = int(sys.argv[shift+1])
# Line 618  Line 623 
623          opr_outer = id_toOpr(t_outer)          opr_outer = id_toOpr(t_outer)
624          opr_inner = id_toOpr(t_inner)          opr_inner = id_toOpr(t_inner)
625          writeTitle_outer(opr_inner, opr_outer)          writeTitle_outer(opr_inner, opr_outer)
626          embed_base_iter_ty2_wihty1(opr_inner, opr_outer, t_num)          ex = oprToEx(opr_inner, args_types)
627            embed_base_iter_ty2_wihty1(ex, opr_inner, opr_outer, t_num)
628          writeResults_outer(opr_inner, opr_outer)          writeResults_outer(opr_inner, opr_outer)
629      elif(args==4):      elif(args==4):
630          #  run a specific iterate over double layer with unary operator          #  run a specific iterate over double layer with unary operator
# Line 629  Line 635 
635          opr_outer = id_toOpr(t_outer)          opr_outer = id_toOpr(t_outer)
636          opr_inner = id_toOpr(t_inner)          opr_inner = id_toOpr(t_inner)
637          writeTitle_outer(opr_inner, opr_outer)          writeTitle_outer(opr_inner, opr_outer)
638          embed_base_specific_ex(opr_inner, opr_outer, t_num, t_ty2)          ex = oprToEx(opr_inner, args_types)
639            embed_base_specific_ex(ex, opr_inner, opr_outer, t_num, t_ty2)
640          writeResults_outer(opr_inner, opr_outer)          writeResults_outer(opr_inner, opr_outer)
641    
642  else:  else:

Legend:
Removed from v.4455  
changed lines
  Added in v.4456

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0