def __init__(self, input_values, inst: tik.Tik): self.tik_instance = inst dtype = "int64" # data in tiling_gm likes: # 0---- 1---- 2---- 3---- # axis, out_dim, max_inner_dim, min_inner_dim, # 4---- 5---- # output_inner_length, input_count # 6---- 7---- # reserve, reserve # 8---- 9---- # first_inner_dims, first_output_idx, # second_inner_dims, second_output_idx # ... self.dtype = dtype self.input_values = input_values self.axis = inst.Scalar(dtype, name="axis") self.out_dim = inst.Scalar(dtype, name="out_dim") self.max_inner_dim = inst.Scalar(dtype, name="max_inner_dim") self.min_inner_dim = inst.Scalar(dtype, name="min_inner_dim") self.output_inner_length = inst.Scalar(dtype, name="output_inner_length") tiling_ub_size = max(len(input_values) * 2, 8) tiling_gm_size = 8 + tiling_ub_size tiling_gm_size = ceil_32bytes_align_count(tiling_gm_size, dtype) tiling_ub_size = ceil_32bytes_align_count(tiling_ub_size, dtype) self.tiling_ub_size = tiling_ub_size self.tiling_gm = inst.Tensor(dtype, (tiling_gm_size, ), name="tiling_gm", scope=tik.scope_gm) self._need_ub_size = (self.tiling_ub_size * common_util.get_data_size(dtype)) self._tiling_ub = None self._out_dim = None self._inner_dim = None
def __init__(self, input_x_shape, inst: tik.Tik): """ tiling param :param input_x_shape: input shape :param inst: tik instance """ self.tik_instance = inst dtype = "int64" self.dtype = dtype # input_shape, output_shape, begin, end, stride tiling_gm_size = len(input_x_shape) * 5 self.tiling_gm = inst.Tensor(dtype, (tiling_gm_size,), name="tiling_gm", scope=tik.scope_gm) def gen_shape(name, index): name += str(index) return inst.Scalar(dtype, name=name) self.input_shape = tuple(map(lambda x: gen_shape("input_dim", x[0]), enumerate(input_x_shape))) self.begin = tuple(map(lambda x: gen_shape("begin_", x[0]), enumerate(input_x_shape))) self.end = tuple(map(lambda x: gen_shape("end_", x[0]), enumerate(input_x_shape))) self.stride = tuple(map(lambda x: gen_shape("stride_", x[0]), enumerate(input_x_shape))) self.output_shape = tuple(map(lambda x: gen_shape("out_dim_", x[0]), enumerate(input_x_shape))) self.out_dim = inst.Scalar(dtype, name="out_dim")