Пример #1
0
 def visit_PointerCast(self, o):
     """
     Build cgen pointer casts for an :class:`Object`.
     """
     ctype = ctypes_to_C(o.object.dtype)
     lvalue = c.Pointer(c.Value(ctype, o.object.name))
     rvalue = '(%s*) %s' % (ctype, '_%s' % o.object.name)
     return c.Initializer(lvalue, rvalue)
Пример #2
0
 def _args_cast(self, args):
     """Build cgen type casts for an iterable of :class:`Argument`."""
     ret = []
     for i in args:
         if i.is_TensorArgument:
             align = "__attribute__((aligned(64)))"
             shape = ''.join(
                 ["[%s]" % ccode(j) for j in i.provider.symbolic_shape[1:]])
             lvalue = c.POD(i.dtype,
                            '(*restrict %s)%s %s' % (i.name, shape, align))
             rvalue = '(%s (*)%s) %s' % (c.dtype_to_ctype(
                 i.dtype), shape, '%s_vec' % i.name)
             ret.append(c.Initializer(lvalue, rvalue))
         elif i.is_PtrArgument:
             ctype = ctypes_to_C(i.dtype)
             lvalue = c.Pointer(c.Value(ctype, i.name))
             rvalue = '(%s*) %s' % (ctype, '_%s' % i.name)
             ret.append(c.Initializer(lvalue, rvalue))
     return ret
Пример #3
0
 def ctype(self):
     return ctypes_to_C(self.dtype)