Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize container views #1505

Merged
merged 10 commits into from
Feb 20, 2024
4 changes: 2 additions & 2 deletions dace/codegen/dispatcher.py
Original file line number Diff line number Diff line change
@@ -505,11 +505,11 @@ def get_copy_dispatcher(self, src_node, dst_node, edge, sdfg, state):
dst_is_data = True

# Skip copies to/from views where edge matches
if src_is_data and isinstance(src_node.desc(sdfg), (dt.StructureView, dt.View)):
if src_is_data and isinstance(src_node.desc(sdfg), dt.View):
e = sdutil.get_view_edge(state, src_node)
if e is edge:
return None
if dst_is_data and isinstance(dst_node.desc(sdfg), (dt.StructureView, dt.View)):
if dst_is_data and isinstance(dst_node.desc(sdfg), dt.View):
e = sdutil.get_view_edge(state, dst_node)
if e is edge:
return None
6 changes: 3 additions & 3 deletions dace/codegen/targets/cpu.py
Original file line number Diff line number Diff line change
@@ -216,7 +216,7 @@ def allocate_view(self, sdfg: SDFG, dfg: SDFGState, state_id: int, node: nodes.A
is_write=is_write)

# Test for views of container arrays and structs
if isinstance(sdfg.arrays[viewed_dnode.data], (data.Structure, data.ContainerArray)):
if isinstance(sdfg.arrays[viewed_dnode.data], (data.Structure, data.ContainerArray, data.ContainerView)):
vdesc = sdfg.arrays[viewed_dnode.data]
ptrname = cpp.ptr(memlet.data, vdesc, sdfg, self._dispatcher.frame)
field_name = None
@@ -362,7 +362,7 @@ def allocate_array(self, sdfg, dfg, state_id, node, nodedesc, function_stream, d
self.allocate_array(sdfg, dfg, state_id, nodes.AccessNode(f"{name}.{k}"), v, function_stream,
declaration_stream, allocation_stream)
return
if isinstance(nodedesc, (data.StructureView, data.View)):
if isinstance(nodedesc, data.View):
return self.allocate_view(sdfg, dfg, state_id, node, function_stream, declaration_stream, allocation_stream)
if isinstance(nodedesc, data.Reference):
return self.allocate_reference(sdfg, dfg, state_id, node, function_stream, declaration_stream,
@@ -527,7 +527,7 @@ def deallocate_array(self, sdfg, dfg, state_id, node, nodedesc, function_stream,
dtypes.AllocationLifetime.External)
self._dispatcher.declared_arrays.remove(alloc_name, is_global=is_global)

if isinstance(nodedesc, (data.Scalar, data.StructureView, data.View, data.Stream, data.Reference)):
if isinstance(nodedesc, (data.Scalar, data.View, data.Stream, data.Reference)):
return
elif (nodedesc.storage == dtypes.StorageType.CPU_Heap
or (nodedesc.storage == dtypes.StorageType.Register and symbolic.issymbolic(arrsize, sdfg.constants))):
2 changes: 1 addition & 1 deletion dace/codegen/targets/framecode.py
Original file line number Diff line number Diff line change
@@ -751,7 +751,7 @@ def determine_allocation_lifetime(self, top_sdfg: SDFG):
instances = access_instances[sdfg.sdfg_id][name]

# A view gets "allocated" everywhere it appears
if isinstance(desc, (data.StructureView, data.View)):
if isinstance(desc, data.View):
for s, n in instances:
self.to_allocate[s].append((sdfg, s, n, False, True, False))
self.to_allocate[s].append((sdfg, s, n, False, False, True))
Loading