Skip to content
Snippets Groups Projects
Commit dba8975e authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Implement declaration of temporaries with base_storage

parent a6a23077
No related branches found
No related tags found
No related merge requests found
......@@ -80,6 +80,11 @@ def default_declaration(name, shape=(), shape_impl=()):
return '{} {}(0.0);'.format(t, name)
@preamble
def declaration_with_base_storage(name, base_storage):
return 'double* {} = {};'.format(name, base_storage)
class _TemporaryCounter:
counter = 0
......@@ -99,6 +104,13 @@ def temporary_variable(name, **kwargs):
shape_impl = kwargs.pop('shape_impl', ('arr',) * len(shape))
decl_method = kwargs.pop('decl_method', default_declaration)
# Check if a specified base_storage has already been initialized
if kwargs.get('base_storage', None):
assert(kwargs['base_storage'] in [tv.name for tv in temporary_variable._memoize_cache.values()])
assert(decl_method is None)
declaration_with_base_storage(name, kwargs['base_storage'])
if decl_method is not None:
decl_method(name, shape, shape_impl)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment