Skip to content

Commit

Permalink
feat: Refactor WASM module (#1503)
Browse files Browse the repository at this point in the history
* feat: Refactor WASM module

- Add a new WasmModuleHandler class that takes raw wasm_module bytes on construction, but has the same interface as WasmFileHandler.
- WasmFileHandler now inherits from WasmModuleHandler.
- Split checking of the WASM module into a new function so it can be called after initialisation if required.
- Adds new cached properties, bytecode, bytecode_base64 and module_uid which allow lazy loading of the module in encoded form, or computation of a unique identifier for the module.
- Add deprecated properties _check_file, wasm_file_encoded and _wasmfileuid to maintain compatibility with existing versions of pytket-qir and pytket-quantinuum.
- Remove some exceptions that are no longer possible.
  • Loading branch information
johnchildren authored Aug 19, 2024
1 parent e7d13f2 commit 725c5ec
Show file tree
Hide file tree
Showing 3 changed files with 244 additions and 151 deletions.
8 changes: 6 additions & 2 deletions pytket/pytket/circuit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def overload_add_wasm_to_reg(
if args_wasm is None:
args_wasm = [0]

if filehandler._check_file:
if filehandler.checked:
for reg in list_i:
if reg.size > 32:
raise ValueError(
Expand All @@ -150,7 +150,11 @@ def overload_add_wasm_to_reg(
please use only registers of at most 32 bits"""
)

if filehandler.check_function(funcname, len(list_i), len(list_o)):
# If the filehandler has not been checked we allow it to
# be added without checking the function arity.
if not filehandler.checked or filehandler.check_function(
funcname, len(list_i), len(list_o)
):
if (len(args_wasm)) > 0:
self._add_w_register(max(args_wasm) + 1)
return self._add_wasm(
Expand Down
Loading

0 comments on commit 725c5ec

Please sign in to comment.