Example #1
0
    def permute_block_size_according_to_layout(block_size, layout):
        """Returns modified block_size such that the fastest coordinate gets the biggest block dimension"""
        if not is_integer_sequence(block_size):
            return block_size
        sorted_block_size = list(sorted(block_size, reverse=True))
        while len(sorted_block_size) > len(layout):
            sorted_block_size[0] *= sorted_block_size[-1]
            sorted_block_size = sorted_block_size[:-1]

        result = list(block_size)
        for l, bs in zip(reversed(layout), sorted_block_size):
            result[l] = bs
        return tuple(result[:len(layout)])
Example #2
0
 def max_threads_per_block(self):
     if is_integer_sequence(self._block_size):
         return prod(self._block_size)
     else:
         return None
 def __new__(cls, integer, divisor):
     if is_integer_sequence((integer, divisor)):
         return integer // divisor
     else:
         return super().__new__(cls, integer, divisor)
 def __new__(cls, integer, divisor):
     if is_integer_sequence((integer, divisor)):
         return (int(integer) // int(divisor)) * divisor
     else:
         return super().__new__(cls, integer, divisor)
Example #5
0
 def has_fixed_index_shape(self):
     return is_integer_sequence(self.index_shape)