Esempio n. 1
0
    def generate_sid_params(self, sdfg: dace.SDFG):
        res = []
        import dace.data

        for name, array in sdfg.arrays.items():
            if array.transient:
                continue
            domain_dim_flags = tuple(True if any(
                dace.symbolic.pystr_to_symbolic(f"__{dim.upper()}") in
                s.free_symbols for s in array.shape
                if hasattr(s, "free_symbols")) else False for dim in "ijk")
            data_ndim = len(array.shape) - sum(array_dimensions(array))
            sid_def = pybuffer_to_sid(
                name=name,
                ctype=array.dtype.ctype,
                domain_dim_flags=domain_dim_flags,
                data_ndim=data_ndim,
                stride_kind_index=self.unique_index(),
                backend=self.backend,
            )

            res.append(sid_def)
        # pass scalar parameters as variables
        for name in (n for n in sdfg.symbols.keys() if not n.startswith("__")):
            res.append(name)
        return res
Esempio n. 2
0
 def visit_FieldDecl(self, node: cuir.FieldDecl, **kwargs):
     if "external_arg" in kwargs:
         domain_ndim = node.dimensions.count(True)
         data_ndim = len(node.data_dims)
         sid_ndim = domain_ndim + data_ndim
         if kwargs["external_arg"]:
             return "py::buffer {name}, std::array<gt::int_t,{sid_ndim}> {name}_origin".format(
                 name=node.name,
                 sid_ndim=sid_ndim,
             )
         else:
             return pybuffer_to_sid(
                 name=node.name,
                 ctype=self.visit(node.dtype),
                 domain_dim_flags=node.dimensions,
                 data_ndim=len(node.data_dims),
                 stride_kind_index=self.unique_index(),
                 backend=self.backend,
             )