models_mnist/assembler.py [320:363]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    for r_id in range(num_rounds):
      layout = tokens[:, r_id]
      invalid_prog = False
      round_id = weaver.batch_input(executor._loom_types['round'], r_id)
      if fact is not None: fact_slice = weaver.slice_fact(fact, round_id)

      # valid layout must contain <eos>. Assembly fails if it doesn't.
      if not np.any(layout == self.EOS_idx): invalid_prog = True

      decode_stack = []
      penult_out = None # penultimate output
      for t_id in range(len(layout)):
        weights = None
        time = weaver.batch_input(executor._loom_types['time'], t_id)
        text_att = weaver.slice_text(text, round_id, time)

        # slice the text feature
        text_feat_slice = weaver.slice_text_feat(text_feat, round_id, time)

        cur_op_id = layout[t_id]
        cur_op_name = self.module_names[cur_op_id]

        # <eos> would mean stop
        if cur_op_id == self.EOS_idx: break

        # insufficient number of inputs
        num_inputs = _module_input_num[cur_op_name]
        if len(decode_stack) < num_inputs:
          invalid_prog = True
          break

        # read the inputs
        inputs = []
        for ii in range(num_inputs):
          arg, arg_type = decode_stack.pop()
          # cannot consume anything but attention
          if arg_type != 'att':
            invalid_prog = True
            break
          inputs.append(arg)

        # switch cases
        if cur_op_name == '_Find':
          out = weaver.find(image, text_att)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



models_vd/assembler.py [340:383]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    for r_id in range(num_rounds):
      layout = tokens[:, r_id]
      invalid_prog = False
      round_id = weaver.batch_input(executor._loom_types['round'], r_id)
      if fact is not None: fact_slice = weaver.slice_fact(fact, round_id)

      # valid layout must contain <eos>. Assembly fails if it doesn't.
      if not np.any(layout == self.EOS_idx): invalid_prog = True

      decode_stack = []
      penult_out = None # penultimate output
      for t_id in range(len(layout)):
        weights = None
        time = weaver.batch_input(executor._loom_types['time'], t_id)
        text_att = weaver.slice_text(text, round_id, time)

        # slice the text feature
        text_feat_slice = weaver.slice_text_feat(text_feat, round_id, time)

        cur_op_id = layout[t_id]
        cur_op_name = self.module_names[cur_op_id]

        # <eos> would mean stop
        if cur_op_id == self.EOS_idx: break

        # insufficient number of inputs
        num_inputs = _module_input_num[cur_op_name]
        if len(decode_stack) < num_inputs:
          invalid_prog = True
          break

        # read the inputs
        inputs = []
        for ii in range(num_inputs):
          arg, arg_type = decode_stack.pop()
          # cannot consume anything but attention
          if arg_type != 'att':
            invalid_prog = True
            break
          inputs.append(arg)

        # switch cases
        if cur_op_name == '_Find':
          out = weaver.find(image, text_att)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



