diff --git a/dace/cli/sdfgcc.py b/dace/cli/sdfgcc.py index 1df7604b4b..0d04950be7 100644 --- a/dace/cli/sdfgcc.py +++ b/dace/cli/sdfgcc.py @@ -48,7 +48,7 @@ def main(): sdfg = SDFGOptimizer(sdfg).optimize() # Compile SDFG - sdfg.compile(outpath) + sdfg.compile(outpath, return_program_handle=False) # Copying header file to optional path if outpath is not None: diff --git a/dace/cli/sdfv.py b/dace/cli/sdfv.py index 2012debe82..d14059468f 100644 --- a/dace/cli/sdfv.py +++ b/dace/cli/sdfv.py @@ -43,7 +43,11 @@ def view(sdfg: dace.SDFG, filename: Optional[Union[str, int]] = None, verbose: b ): fd, filename = tempfile.mkstemp(suffix='.sdfg') sdfg.save(filename) - os.system(f'code {filename}') + if platform.system() == 'Darwin': + # Special case for MacOS + os.system(f'open {filename}') + else: + os.system(f'code {filename}') os.close(fd) return diff --git a/dace/codegen/compiled_sdfg.py b/dace/codegen/compiled_sdfg.py index 9bfcc439e0..332db028ae 100644 --- a/dace/codegen/compiled_sdfg.py +++ b/dace/codegen/compiled_sdfg.py @@ -518,6 +518,9 @@ def _construct_args(self, kwargs) -> Tuple[Tuple[Any], Tuple[Any]]: # Otherwise, None values are passed as null pointers below elif isinstance(arg, ctypes._Pointer): pass + elif isinstance(arg, str): + # Cast to bytes + arglist[i] = ctypes.c_char_p(arg.encode('utf-8')) else: raise TypeError(f'Passing an object (type {type(arg).__name__}) to an array in argument "{a}"') elif is_array and not is_dtArray: @@ -550,6 +553,8 @@ def _construct_args(self, kwargs) -> Tuple[Tuple[Any], Tuple[Any]]: pass elif isinstance(arg, float) and atype.dtype.type == np.float64: pass + elif isinstance(arg, bool) and atype.dtype.type == np.bool_: + pass elif (isinstance(arg, str) or arg is None) and atype.dtype == dtypes.string: if arg is None: arglist[i] = ctypes.c_char_p(None) diff --git a/dace/codegen/compiler.py b/dace/codegen/compiler.py index 350e141606..236f832cac 100644 --- a/dace/codegen/compiler.py +++ b/dace/codegen/compiler.py @@ -213,7 +213,7 @@ def configure_and_compile(program_folder, program_name=None, output_stream=None) # Clean CMake directory and try once more if Config.get_bool('debugprint'): print('Cleaning CMake build folder and retrying...') - shutil.rmtree(build_folder) + shutil.rmtree(build_folder, ignore_errors=True) os.makedirs(build_folder) try: _run_liveoutput(cmake_command, shell=True, cwd=build_folder, output_stream=output_stream) diff --git a/dace/codegen/cppunparse.py b/dace/codegen/cppunparse.py index edeb5270ca..c375147930 100644 --- a/dace/codegen/cppunparse.py +++ b/dace/codegen/cppunparse.py @@ -555,7 +555,11 @@ def _write_constant(self, value): if result.find("b'") >= 0: self.write(result) else: - self.write(result.replace('\'', '\"')) + towrite = result + if result.startswith("'"): + towrite = result[1:-1].replace('"', '\\"') + towrite = f'"{towrite}"' + self.write(towrite) def _Constant(self, t): value = t.value @@ -1187,6 +1191,8 @@ def py2cpp(code, expr_semicolon=True, defined_symbols=None): return cppunparse(ast.parse(symbolic.symstr(code, cpp_mode=True)), expr_semicolon, defined_symbols=defined_symbols) + elif isinstance(code, int): + return str(code) elif code.__class__.__name__ == 'function': try: code_str = inspect.getsource(code) diff --git a/dace/codegen/tools/type_inference.py b/dace/codegen/tools/type_inference.py index 8f8dd84151..26b369fa9d 100644 --- a/dace/codegen/tools/type_inference.py +++ b/dace/codegen/tools/type_inference.py @@ -375,6 +375,8 @@ def _Compare(t, symbols, inferred_symbols): for o, e in zip(t.ops, t.comparators): if o.__class__.__name__ not in cppunparse.CPPUnparser.cmpops: continue + if isinstance(e, ast.Constant) and e.value is None: + continue inf_type = _dispatch(e, symbols, inferred_symbols) if isinstance(inf_type, dtypes.vector): # Make sure all occuring vectors are of same size diff --git a/dace/dtypes.py b/dace/dtypes.py index a016ac60e2..d0c6f23e03 100644 --- a/dace/dtypes.py +++ b/dace/dtypes.py @@ -404,6 +404,8 @@ def __init__(self, wrapped_type, typename=None): wrapped_type = numpy.bool_ elif getattr(wrapped_type, '__name__', '') == 'bool_' and typename is None: typename = 'bool' + elif wrapped_type is type(None): + wrapped_type = None self.type = wrapped_type # Type in Python self.ctype = _CTYPES[wrapped_type] # Type in C diff --git a/dace/memlet.py b/dace/memlet.py index f78da3a6b7..85bd0a348d 100644 --- a/dace/memlet.py +++ b/dace/memlet.py @@ -555,9 +555,9 @@ def used_symbols(self, all_symbols: bool, edge=None) -> Set[str]: from dace.sdfg import nodes if isinstance(edge.dst, nodes.CodeNode) or isinstance(edge.src, nodes.CodeNode): view_edge = True - elif edge.dst_conn == 'views' and isinstance(edge.dst, nodes.AccessNode): + elif edge.dst_conn and isinstance(edge.dst, nodes.AccessNode): view_edge = True - elif edge.src_conn == 'views' and isinstance(edge.src, nodes.AccessNode): + elif edge.src_conn and isinstance(edge.src, nodes.AccessNode): view_edge = True if not view_edge: diff --git a/dace/properties.py b/dace/properties.py index 09439ce4f8..82be72f9fd 100644 --- a/dace/properties.py +++ b/dace/properties.py @@ -329,7 +329,7 @@ def initialize_properties(obj, *args, **kwargs): for name, prop in own_properties.items(): # Only assign our own properties, so we don't overwrite what's been # set by the base class - if hasattr(obj, name): + if hasattr(obj, '_' + name): raise PropertyError("Property {} already assigned in {}".format(name, type(obj).__name__)) if not prop.indirected: if prop.allow_none or prop.default is not None: diff --git a/dace/runtime/include/dace/stream.h b/dace/runtime/include/dace/stream.h index 255e16ec2b..1f8134fae6 100644 --- a/dace/runtime/include/dace/stream.h +++ b/dace/runtime/include/dace/stream.h @@ -338,7 +338,7 @@ namespace dace { template struct Consume { - template