Skip to content

Commit

Permalink
May Improvements (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
phschaad authored Jun 20, 2023
1 parent b50e0e5 commit 18a82b6
Show file tree
Hide file tree
Showing 48 changed files with 4,876 additions and 11,175 deletions.
14 changes: 11 additions & 3 deletions backend/dace_vscode/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,24 @@ def get_transformations(sdfg_json, selected_elements, permissive):
# an older version of dace (<= 0.13.1) is being used - attempt
# to construct subgraph transformations using the old API.
xform_obj = xform(subgraph)
if xform_obj.can_be_applied(selected_sdfg, subgraph):
transformations.append(xform_obj.to_json())
docstrings[xform.__name__] = xform_obj.__doc__
try:
if xform_obj.can_be_applied(selected_sdfg, subgraph):
transformations.append(xform_obj.to_json())
docstrings[xform.__name__] = xform_obj.__doc__
except Exception as can_be_applied_exception:
# If something fails here, that is most likely due to a
# transformation bug. Fail gracefully.
print('Warning: ' + xform.__name__ + ' caused an exception')
print(can_be_applied_exception)
print('Most likely a transformation bug, ignoring...')

utils.restore_save_metadata(old_meta)
return {
'transformations': transformations,
'docstrings': docstrings,
}
except Exception as e:
traceback.print_exc()
return {
'error': {
'message': 'Failed to load transformations',
Expand Down
10 changes: 6 additions & 4 deletions backend/run_dace.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import sys
from argparse import ArgumentParser
from os import path
import json

# Then, load the rest of the modules
import aenum
Expand All @@ -54,7 +55,8 @@

from dace_vscode import arith_ops, transformations
from dace_vscode.utils import (disable_save_metadata, get_exception_message,
load_sdfg_from_file, restore_save_metadata)
load_sdfg_from_file, restore_save_metadata,
load_sdfg_from_json)

meta_dict = {}

Expand Down Expand Up @@ -296,10 +298,10 @@ def compile_sdfg(path, suppress_instrumentation=False):
}


def specialize_sdfg(path, symbol_map, remove_undef=True):
def specialize_sdfg(sdfg_string, symbol_map, remove_undef=True):
old_meta = disable_save_metadata()

loaded = load_sdfg_from_file(path)
loaded = load_sdfg_from_json(json.loads(sdfg_string))
if loaded['error'] is not None:
return loaded['error']
sdfg: dace.sdfg.SDFG = loaded['sdfg']
Expand Down Expand Up @@ -414,7 +416,7 @@ def _compile_sdfg_from_file():
@daemon.route('/specialize_sdfg', methods=['POST'])
def _specialize_sdfg():
request_json = request.get_json()
return specialize_sdfg(request_json['path'], request_json['symbol_map'])
return specialize_sdfg(request_json['sdfg'], request_json['symbol_map'])

@daemon.route('/get_metadata', methods=['GET'])
def _get_metadata():
Expand Down
65 changes: 65 additions & 0 deletions media/components/dace/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!-- Copyright 2020-2022 ETH Zurich and the DaCe-VSCode authors. -->
<!-- All rights reserved. -->

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Transformation List</title>

<script>
// Reference to the VSCode API.
let vscode = undefined;
</script>
</head>

<body>
<div id="contents" class="container-fluid">
<div class="row mb-2">
<div class="col-12">
<span>
Status:&nbsp;<span id="status-text" class="not-connected">
Not connected
</span>
</span>
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<div class="d-flex gap-1">
<button class="btn btn-sm btn-primary flex-fill"
id="launch-btn">
Launch
</button>
<button class="btn btn-sm btn-secondary flex-fill"
id="connect-btn">
Connect
</button>
<button class="btn btn-sm btn-outline-danger flex-fill"
id="quit-btn"
disabled="disabled">
Stop
</button>
</div>
</div>
</div>
<div class="row mb-2">
<div class="input-group input-group-sm col-12">
<label for="inputPort" class="input-group-text">
Port
</label>
<input type="number" class="form-control" id="inputPort">
</div>
</div>
</div>

<script src="{{ SCRIPT_SRC }}/dace.js"></script>
<script>
vscode = acquireVsCodeApi();
</script>
</body>

</html>

11 changes: 10 additions & 1 deletion media/components/sdfv/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// Reference to the VSCode API.
let vscode = undefined;
let SPLIT_DIRECTION = 'vertical';
let MINIMAP_ENABLED = true;
</script>

<script src="{{ SCRIPT_SRC }}/pdfkit.standalone.js"></script>
Expand Down Expand Up @@ -188,6 +187,16 @@ <h5 class="offcanvas-title" id="info-title"></h5>
<span>Go to Generated Code</span>
</div>
</div>
<div id="edge-btns-container">
<div class="button" id="goto-edge-start"
style="display: none;">
<span>Jump to Start</span>
</div>
<div class="button" id="goto-edge-end"
style="display: none;">
<span>Jump to End</span>
</div>
</div>
</div>
<div id="info-header-btn-container">
<div id="layout-toggle-btn" class="vertical"
Expand Down
Loading

0 comments on commit 18a82b6

Please sign in to comment.