How to use the opentuner.search.manipulator.PermutationParameter function in opentuner

To help you get started, we’ve selected a few opentuner examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jansel / opentuner / tests / test_manipulator.py View on Github external
def setUp(self):
        """
        Set up a few configurations. The values of the PermutationParameter are:
        config1 - 0 1 2 3 4 5 6 7 8 9
        config2 - 4 3 2 1 0 9 8 7 6 5
        config3 - 1 0 4 2 7 9 5 3 6 8

        """
        self.manipulator = manipulator.ConfigurationManipulator()
        self.param1 = manipulator.PermutationParameter("param1", [0,1,2,3,4,5,6,7,8,9])
        self.manipulator.add_parameter(self.param1)

        self.cfg = self.manipulator.seed_config()
        self.config1 = self.manipulator.seed_config()
        self.config2 = self.manipulator.seed_config()
        self.config3 = self.manipulator.seed_config()

        # repeating values
        self.config4 = self.manipulator.seed_config()
        self.config5 = self.manipulator.seed_config()


        self.param1.set_value(self.config1, [0,1,2,3,4,5,6,7,8,9])
        self.param1.set_value(self.config2, [4,3,2,1,0,9,8,7,6,5])
        self.param1.set_value(self.config3, [1,0,4,2,7,9,5,3,6,8])
github jansel / opentuner / tests / test_technique.py View on Github external
def test_get_default_oeprator(self):
    default = self.technique.get_default_operator(manipulator.PermutationParameter)
    self.assertDictEqual(default, {'op_name': 'op1_nop', 'args': [], 'kwargs': {}})
github jansel / opentuner / tests / test_technique.py View on Github external
def setUp(self):
    self.operator_map = {}
    ComposableEvolutionaryTechnique.add_to_map(self.operator_map,
                                  manipulator.PermutationParameter,
                                  "op3_cross", xchoice='op3_cross_CX')
    ComposableEvolutionaryTechnique.add_to_map(self.operator_map,
                                  "FloatArray",
                                  "op3_cross", strength=0.4)
    self.technique = EmptyComposableEvolutionaryTechnique(operator_map = self.operator_map)
github jansel / opentuner / examples / tsp / tsp.py View on Github external
def manipulator(self):
        manipulator = ConfigurationManipulator()
        manipulator.add_parameter(PermutationParameter(0, list(range(len(self.distance)))))
        return manipulator
github jansel / opentuner / opentuner / search / manipulator.py View on Github external
def __init__(self, name, choices, max_cutoff,
               order_class=PermutationParameter,
               offset_class=LogIntegerParameter):
    super(SelectorParameter, self).__init__(name)
    self.choices = choices
    self.max_cutoff = max_cutoff
    self.order_param = order_class('{0}/order'.format(name), choices)
    self.offset_params = [
        offset_class('{0}/offsets/{1}'.format(name, i), 0, max_cutoff)
        for i in range(len(choices) - 1)]
github jansel / opentuner / opentuner / search / manipulator.py View on Github external
def __init__(self, name, items):
    super(PermutationParameter, self).__init__(name)
    self._items = list(items)
    self.size = len(items)
github jansel / opentuner / examples / halide / halidetuner.py View on Github external
def manipulator(self):
    """
    The definition of the manipulator is meant to mimic the Halide::Schedule
    data structure and defines the configuration space to search
    """
    manipulator = HalideConfigurationManipulator(self)
    manipulator.add_parameter(HalideComputeAtScheduleParameter(
      'schedule', self.args, self.settings['functions'],
      self.post_dominators))
    for func in self.settings['functions']:
      name = func['name']
      manipulator.add_parameter(PermutationParameter(
        '{0}_store_order'.format(name), func['vars']))
      manipulator.add_parameter(
        BooleanParameter('{0}_store_order_enabled'.format(name)))
      manipulator.add_parameter(self.compute_order_parameter(func))
      for var in func['vars']:
        manipulator.add_parameter(PowerOfTwoParameter(
          '{0}_vectorize'.format(name), 1, self.args.max_split_factor))
        manipulator.add_parameter(PowerOfTwoParameter(
          '{0}_unroll'.format(name), 1, self.args.max_split_factor))
        manipulator.add_parameter(BooleanParameter(
          '{0}_parallel'.format(name)))
        for nesting in range(1, self.args.nesting):
          manipulator.add_parameter(PowerOfTwoParameter(
            '{0}_splitfactor_{1}_{2}'.format(name, nesting, var),
            1, self.args.max_split_factor))
github jansel / opentuner / opentuner / search / manipulator.py View on Github external
p1 = self.get_value(cfg1)
    p2 = self.get_value(cfg2)
    c1 = p1[:]
    c2 = p2[:]
    # Randomly find cut points
    # Todo: treat path as circle i.e. allow cross-boundary cuts
    r1 = random.randint(0, len(p1) - d)
    r2 = random.randint(0, len(p1) - d)
    [c1.remove(i) for i in p2[r2:r2 + d]]
    self.set_value(cfg, c1[:r1] + p2[r2:r2 + d] + c1[r1:])

  def search_space_size(self):
    return math.factorial(max(1, len(self._items)))


class ScheduleParameter(PermutationParameter):
  def __init__(self, name, items, deps):
    super(ScheduleParameter, self).__init__(name, items)
    self.deps = dict((k, set(v)) for k, v in list(deps.items()))
    log.debug("ScheduleParameter(%s, %s, %s)", repr(name), repr(items),
              repr(deps))
    self._expand_deps()

  def _expand_deps(self):
    """expand self.deps to include recursive dependencies"""
    fixed_point = False
    while not fixed_point:
      fixed_point = True
      for k in list(self.deps.keys()):
        oldlen = len(self.deps[k])
        for dep in list(self.deps[k]):
          if dep in self.deps:
github jbosboom / streamjit / lib / opentuner / streamjit / sjparameters.py View on Github external
return self.universe

	def getUniverseType(self):
		return self.universeType

	def update_value_for_json(self, config):
		self.value = self._get(config)

	def json_replacement(self):
		return {"name": self.name,
			"value": self.value,
			"universeType": self.universeType,
			"universe": self.universe,
			"class": self.javaClass}

class sjPermutationParameter(PermutationParameter):
	def __init__(self, name, universeType, universe, javaClass):
		self.javaClass = javaClass
		self.universeType = universeType
		self.universe = universe
		super(sjPermutationParameter, self).__init__(name, universe)

	def update_value_for_json(self, config):
		self.value = self._get(config)

	def json_replacement(self):
		return {"name": self.name,
			"universeType": self.universeType,
			"universe": self.universe,
			"class": self.javaClass}

class sjCompositionParameter(ArrayParameter):