(self, size_var, lhs, scope, loc)
return out, tuple_var
OneD_Var allocs use sizes of other OneD_var variables,
        so find the local size of those variables (since we transform
        to use global size)
OneD_Var allocs use sizes of other OneD_var variables,
        so find the local size of those variables (since we transform
        to use global size)
OneD_Var allocs use sizes of other OneD_var variables so find the local size of those variables ( since we transform to use global size )
def _fix_1D_Var_alloc(self, size_var, lhs, scope, loc):
        """ OneD_Var allocs use sizes of other OneD_var variables,
        so find the local size of those variables (since we transform
        to use global size)
        """
        out = []
        new_size_var = None

        # size is single int var
        if isinstance(size_var, ir.Var) and isinstance(self.state.typemap[size_var.name], types.Integer):
            # array could be allocated inside 1D_Var nodes like sort
            if size_var.name not in self.oneDVar_len_vars:
                return [], size_var
            # assert size_var.name in self.oneDVar_len_vars, "invalid 1DVar alloc"
            arr_var = self.oneDVar_len_vars[size_var.name]

            def f(oneD_var_arr):  # pragma: no cover
                arr_len = len(oneD_var_arr)
            f_block = compile_to_numba_ir(f, {'sdc': sdc}, self.state.typingctx,
                                          (self.state.typemap[arr_var.name],),
                                          self.state.typemap, self.state.calltypes).blocks.popitem()[1]
            replace_arg_nodes(f_block, [arr_var])
            out = f_block.body[:-3]  # remove none return
            new_size_var = out[-1].target
            return out, new_size_var

        # tuple variable of ints
        if isinstance(size_var, ir.Var):
            # see if size_var is a 1D_Var array's shape
            # it is already the local size, no need to transform
            var_def = guard(get_definition, self.state.func_ir, size_var)
            oned_var_varnames = set(v for v in self._dist_analysis.array_dists
                                    if self._dist_analysis.array_dists[v] == Distribution.OneD_Var)
            if (isinstance(var_def, ir.Expr) and var_def.op == 'getattr'
                    and var_def.attr == 'shape' and var_def.value.name in oned_var_varnames):
                return out, size_var
            # size should be either int or tuple of ints
            #assert size_var.name in self._tuple_table
            # self._tuple_table[size_var.name]
            size_list = self._get_tuple_varlist(size_var, out)
            size_list = [ir_utils.convert_size_to_var(s, self.state.typemap, scope, loc, out)
                         for s in size_list]
        # tuple of int vars
        else:
            assert isinstance(size_var, (tuple, list))
            size_list = list(size_var)

        arr_var = self.oneDVar_len_vars[size_list[0].name]

        def f(oneD_var_arr):  # pragma: no cover
            arr_len = len(oneD_var_arr)
        f_block = compile_to_numba_ir(f, {'sdc': sdc}, self.state.typingctx,
                                      (self.state.typemap[arr_var.name],),
                                      self.state.typemap, self.state.calltypes).blocks.popitem()[1]
        replace_arg_nodes(f_block, [arr_var])
        nodes = f_block.body[:-3]  # remove none return
        new_size_var = nodes[-1].target
        out += nodes

        ndims = len(size_list)
        new_size_list = copy.copy(size_list)
        new_size_list[0] = new_size_var
        tuple_var = ir.Var(scope, mk_unique_var("$tuple_var"), loc)
        self.state.typemap[tuple_var.name] = types.containers.UniTuple(
            types.intp, ndims)
        tuple_call = ir.Expr.build_tuple(new_size_list, loc)
        tuple_assign = ir.Assign(tuple_call, tuple_var, loc)
        out.append(tuple_assign)
        self.state.func_ir._definitions[tuple_var.name] = [tuple_call]
        return out, tuple_var
def _fix_1D_Var_alloc ( self , size_var , lhs , scope , loc ) : out = [ ] new_size_var = None # size is single int var if isinstance ( size_var , ir . Var ) and isinstance ( self . state . typemap [ size_var . name ] , types . Integer ) : # array could be allocated inside 1D_Var nodes like sort if size_var . name not in self . oneDVar_len_vars : return [ ] , size_var # assert size_var.name in self.oneDVar_len_vars, "invalid 1DVar alloc" arr_var = self . oneDVar_len_vars [ size_var . name ] def f ( oneD_var_arr ) : # pragma: no cover arr_len = len ( oneD_var_arr ) f_block = compile_to_numba_ir ( f , { 'sdc' : sdc } , self . state . typingctx , ( self . state . typemap [ arr_var . name ] , ) , self . state . typemap , self . state . calltypes ) . blocks . popitem ( ) [ 1 ] replace_arg_nodes ( f_block , [ arr_var ] ) out = f_block . body [ : - 3 ] # remove none return new_size_var = out [ - 1 ] . target return out , new_size_var # tuple variable of ints if isinstance ( size_var , ir . Var ) : # see if size_var is a 1D_Var array's shape # it is already the local size, no need to transform var_def = guard ( get_definition , self . state . func_ir , size_var ) oned_var_varnames = set ( v for v in self . _dist_analysis . array_dists if self . _dist_analysis . array_dists [ v ] == Distribution . OneD_Var ) if ( isinstance ( var_def , ir . Expr ) and var_def . op == 'getattr' and var_def . attr == 'shape' and var_def . value . name in oned_var_varnames ) : return out , size_var # size should be either int or tuple of ints #assert size_var.name in self._tuple_table # self._tuple_table[size_var.name] size_list = self . _get_tuple_varlist ( size_var , out ) size_list = [ ir_utils . convert_size_to_var ( s , self . state . typemap , scope , loc , out ) for s in size_list ] # tuple of int vars else : assert isinstance ( size_var , ( tuple , list ) ) size_list = list ( size_var ) arr_var = self . oneDVar_len_vars [ size_list [ 0 ] . name ] def f ( oneD_var_arr ) : # pragma: no cover arr_len = len ( oneD_var_arr ) f_block = compile_to_numba_ir ( f , { 'sdc' : sdc } , self . state . typingctx , ( self . state . typemap [ arr_var . name ] , ) , self . state . typemap , self . state . calltypes ) . blocks . popitem ( ) [ 1 ] replace_arg_nodes ( f_block , [ arr_var ] ) nodes = f_block . body [ : - 3 ] # remove none return new_size_var = nodes [ - 1 ] . target out += nodes ndims = len ( size_list ) new_size_list = copy . copy ( size_list ) new_size_list [ 0 ] = new_size_var tuple_var = ir . Var ( scope , mk_unique_var ( "$tuple_var" ) , loc ) self . state . typemap [ tuple_var . name ] = types . containers . UniTuple ( types . intp , ndims ) tuple_call = ir . Expr . build_tuple ( new_size_list , loc ) tuple_assign = ir . Assign ( tuple_call , tuple_var , loc ) out . append ( tuple_assign ) self . state . func_ir . _definitions [ tuple_var . name ] = [ tuple_call ] return out , tuple_var