Skip to content

Better detection of dtype in TemporaryVariable initialization

This fix allows the user to initialize a temporary variable as follows:

var_int = np.random.randint(1000, size=n, dtype=np.int32)
var = lp.TemporaryVariable('var', initializer=var_int,
                           scope=scopes.PRIVATE,
                           read_only=True,
                           dtype=np.int32)

Previously, it would result in the following error:

  File "loopy/kernel/data.py", line 385, in __init__
    elif dtype.numpy_dtype != initializer.dtype:
AttributeError: type object 'numpy.int32' has no attribute 'numpy_dtype'

This now supports passing of regular dtypes or NumpyType's

Merge request reports

Loading