def _setup_loom_ops()

in tensorflow_fold/loom/loom.py [0:0]


  def _setup_loom_ops(self, named_ops):
    """Sets up mappings between loom ops, loom op ids, and loom op names."""
    # Make a PassThroughOp for each TypeShape. Then set up mappings between
    # names, op indices and ops with the PassThrough ops having the same
    # indices as their type_shapes and no names.
    pass_through_ops = [PassThroughLoomOp(ts) for ts in self._type_shapes]

    non_passthrough_op_names = sorted(six.iterkeys(named_ops))

    # _loom_op_names: a list of names for all the ops (including autogenerated
    # names for the PassThroughLoomOps for debugging purposes.)
    #
    # The first len(self._type_shapes) ops are forced to be the passthrough ops
    # for the corresponding TypeShape.  This is enforced in VerifyLoomMetadata.
    self._loom_op_names = (
        [self._pass_through_name(ts) for ts in self._type_shapes] +
        non_passthrough_op_names)

    # _loom_ops: a list of the supported LoomOps (including autogenerated
    # PassThroughOps)
    self._loom_ops = (
        pass_through_ops + [named_ops[k] for k in non_passthrough_op_names])

    # _loom_total_args: The sum of the number of arguments across all loom ops.
    self._loom_total_args = sum(
        len(op.input_type_shapes) for op in self._loom_ops)

    # _loom_op_name_to_idx: a dict mapping the names in '_op_names' back to into
    # indices usable with '_ops' and '_op_names'.
    self._loom_op_name_to_idx = {
        name: idx for idx, name in enumerate(self._loom_op_names)}