Пример #1
0
 def visit_Subscript(self, node: ast.Subscript) -> Any:
     # Convert subscript to symbol name
     node_name = astutils.rname(node)
     if node_name in self.iconns:
         self.latest[node_name] += 1
         new_name = f'{node_name}_{self.latest[node_name]}'
         subset = subsets.Range(
             astutils.subscript_to_slice(node, self.sdfg.arrays)[1])
         # Check if range can be collapsed
         if _range_is_promotable(subset, self.defined):
             self.in_mapping[new_name] = (node_name, subset)
             return ast.copy_location(ast.Name(id=new_name, ctx=ast.Load()),
                                      node)
         else:
             self.do_not_remove.add(node_name)
     elif node_name in self.oconns:
         self.latest[node_name] += 1
         new_name = f'{node_name}_{self.latest[node_name]}'
         subset = subsets.Range(
             astutils.subscript_to_slice(node, self.sdfg.arrays)[1])
         # Check if range can be collapsed
         if _range_is_promotable(subset, self.defined):
             self.out_mapping[new_name] = (node_name, subset)
             return ast.copy_location(
                 ast.Name(id=new_name, ctx=ast.Store()), node)
         else:
             self.do_not_remove.add(node_name)
     return self.generic_visit(node)
Пример #2
0
    def _Subscript(self, t: ast.Subscript):
        from dace.frontend.python.astutils import subscript_to_slice
        target, rng = subscript_to_slice(t, self.sdfg.arrays)
        rng = subsets.Range(rng)
        if rng.num_elements() != 1:
            raise SyntaxError(
                'Range subscripts disallowed in interstate edges')

        memlet = mmlt.Memlet(data=target, subset=rng)
        self.write(cpp_array_expr(self.sdfg, memlet))
Пример #3
0
    def visit_Subscript(self, node: ast.Subscript) -> ast.Subscript:
        if astutils.rname(node.value) == self.to_refine:
            rng = subsets.Range(
                astutils.subscript_to_slice(node,
                                            self.sdfg.arrays,
                                            without_array=True))
            rng.offset(self.subset, True, self.indices)
            return ast.copy_location(
                astutils.slice_to_subscript(self.to_refine, rng), node)

        return self.generic_visit(node)