Skip to content

Commit

Permalink
Data Container Editing and 'Offline' Editing of SDFGs (#134)
Browse files Browse the repository at this point in the history
Co-authored-by: Tal Ben-Nun <tbennun@users.noreply.github.com>
  • Loading branch information
phschaad and tbennun authored Apr 25, 2022
1 parent 9fe464c commit 9319658
Show file tree
Hide file tree
Showing 12 changed files with 629 additions and 240 deletions.
4 changes: 2 additions & 2 deletions backend/dace_vscode/editing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# All rights reserved.

from dace import (
serialize, nodes, SDFG, SDFGState, InterstateEdge, Memlet, dtypes
nodes, SDFG, SDFGState, InterstateEdge, Memlet, dtypes
)
from dace_vscode.utils import (
load_sdfg_from_json,
Expand Down Expand Up @@ -98,7 +98,7 @@ def insert_sdfg_element(sdfg_str, type, parent_uuid, edge_a_uuid):
sub_sdfg = SDFG('nested_sdfg')
sub_sdfg.add_array('in', [1], dtypes.float32)
sub_sdfg.add_array('out', [1], dtypes.float32)

nsdfg = parent.add_nested_sdfg(sub_sdfg, sdfg, {'in'}, {'out'})
uuid = [get_uuid(nsdfg, parent)]
elif type == 'LibraryNode':
Expand Down
16 changes: 14 additions & 2 deletions backend/run_dace.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#####################################################################
# Before importing anything, try to take the ".env" file into account
import json
import os
import re
import sys
Expand Down Expand Up @@ -56,14 +57,21 @@
)
from dace_vscode import transformations, editing, arith_ops

meta_dict = {}

def get_property_metdata():
def get_property_metdata(force_regenerate=False):
""" Generate a dictionary of class properties and their metadata.
This iterates over all classes registered as serializable in DaCe's
serialization module, checks whether there are properties present
(true for any class registered via the @make.properties decorator), and
then assembels their metadata to a dictionary.
"""
# If a cached version of the dictionary is available, return that.
if meta_dict and not force_regenerate:
return {
'metaDict': meta_dict,
}

# Lazy import to cut down on module load time.
from dace.sdfg.nodes import full_class_path

Expand All @@ -77,9 +85,10 @@ def get_property_metdata():
from dace.transformation import optimizer
_ = optimizer.Optimizer(dace.SDFG('dummy')).get_pattern_matches()

meta_dict = {}
meta_dict.clear()
meta_dict['__reverse_type_lookup__'] = {}
meta_dict['__libs__'] = {}
meta_dict['__data_container_types__'] = {}
for typename in dace.serialize._DACE_SERIALIZE_TYPES:
t = dace.serialize._DACE_SERIALIZE_TYPES[typename]
if hasattr(t, '__properties__'):
Expand Down Expand Up @@ -134,9 +143,12 @@ def get_property_metdata():

# For library nodes we want to make sure they are all easily
# accessible under '__libs__', to be able to list them all out.
# Same for data container types.
if (issubclass(t, dace.sdfg.nodes.LibraryNode)
and not t == dace.sdfg.nodes.LibraryNode):
meta_dict['__libs__'][typename] = meta_key
elif (issubclass(t, dace.data.Data) and t is not dace.data.Data):
meta_dict['__data_container_types__'][typename] = meta_key

# Save a lookup for enum values not present yet.
enum_list = [
Expand Down
146 changes: 73 additions & 73 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sdfv",
"displayName": "DaCe SDFG Editor",
"description": "Transform and optimize data-centric programs with a click of a button",
"version": "1.0.15",
"version": "1.1.0",
"engines": {
"vscode": "^1.55.0"
},
Expand Down
Loading

0 comments on commit 9319658

Please sign in to comment.