How to use the ptype.ScalarT function in ptype

To help you get started, we’ve selected a few ptype examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iskandr / parakeet / llvm_runtime.py View on Github external
def generic_value_to_scalar(gv, t):
  assert isinstance(t, ptype.ScalarT), "Expected %s to be scalar" % t
  if isinstance(t, ptype.IntT):
    x = gv.as_int()
  else:
    assert isinstance(t, ptype.FloatT)
    x = gv.as_real(dtype_to_lltype(t.dtype))
  return t.dtype.type(x)
github iskandr / parakeet / llvm_compiled_fn.py View on Github external
def python_to_generic_value(x, t):
  if isinstance(t, ptype.ScalarT):
    return scalar_to_generic_value(x,t)
  else:
    ctypes_struct = t.to_ctypes(x)
    return GenericValue.pointer(ctypes.addressof(ctypes_struct))