Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 2f65c69

Browse files
committed
xsmm config draft
1 parent 5dee994 commit 2f65c69

File tree

5 files changed

+51
-2
lines changed

5 files changed

+51
-2
lines changed

.github/workflows/execute-test-script.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
shell: bash -el {0}
8383
run: |
8484
case "${{ inputs.compiler }}" in
85-
torch_mlir)
85+
torch_mlir | torch_mlir_xsmm)
8686
echo conda_env=mlir-dev >> $GITHUB_OUTPUT;;
8787
ipex)
8888
echo conda_env=ipex >> $GITHUB_OUTPUT;;

.github/workflows/test-single-config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ on:
2424
- torchscript_onednn
2525
- ipex
2626
- torch_mlir
27+
- torch_mlir_xsmm
2728
tag:
2829
description: tag to label this run in DB
2930
required: true

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ jobs:
5252
{device: 'cpu', compiler: 'torchscript_onednn'},
5353
{device: 'cpu', compiler: 'ipex'},
5454
# {device: 'xpu', compiler: 'ipex'},
55-
{device: 'cpu', compiler: 'torch_mlir'}
55+
{device: 'cpu', compiler: 'torch_mlir'},
56+
{device: 'cpu', compiler: 'torch_mlir_xsmm'}
5657
]
5758
test_script: ${{ fromJson(inputs.test_scripts) }}
5859
fail-fast: false

dl_bench/cli/launcher.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def parse_args():
8282
"torchscript_onednn",
8383
"ipex",
8484
"torch_mlir",
85+
"torch_mlir_xsmm",
8586
],
8687
help="Compilation mode to use. No compilation by default.",
8788
)

dl_bench/utils.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,52 @@ def eval(self):
229229

230230
compiled_model = result()
231231
print("Compiled with torch_mlir")
232+
elif compile_mode == "torch_mlir_xsmm":
233+
from torch_mlir._dynamo_fx_importer import import_fx_graph_as_func
234+
from torch_mlir_e2e_test.configs.torchdynamo import jit
235+
from torch_mlir_e2e_test.framework import TestOptions
236+
237+
# from torch_mlir_e2e_test.linalg_on_tensors_backends.refbackend import RefBackendLinalgOnTensorsBackend
238+
from torch_mlir_e2e_test.linalg_on_tensors_backends.xsmmprotobackend import (
239+
XsmmProtoLinalgOnTensorsBackend,
240+
)
241+
import torch.utils._pytree as pytree
242+
243+
# debug_timer seems to cause problems:
244+
# TypeError: TestOptions.__init__() got an unexpected keyword argument 'debug_timer'
245+
# opts = TestOptions(debug_timer=False, use_kernels=True)
246+
opts = TestOptions()
247+
module = jit(
248+
model,
249+
[sample_input],
250+
"test_name",
251+
opts,
252+
output_type="linalg-on-tensors",
253+
)
254+
backend = XsmmProtoLinalgOnTensorsBackend(opts)
255+
# backend = RefBackendLinalgOnTensorsBackend()
256+
module = backend.compile(module)
257+
backend_module = backend.load(module)
258+
259+
params = {
260+
**dict(model.named_parameters(remove_duplicate=False)),
261+
**dict(model.named_buffers(remove_duplicate=False)),
262+
}
263+
params_flat, params_spec = pytree.tree_flatten(params)
264+
params_flat = list(params_flat)
265+
266+
class result:
267+
def __call__(self, *args):
268+
numpy_inputs = recursively_convert_to_numpy(params_flat + [*args])
269+
return refine_result_type(
270+
getattr(backend_module, model.__class__.__name__)(*numpy_inputs)
271+
)
272+
273+
def eval(self):
274+
pass
275+
276+
compiled_model = result()
277+
print("Compiled with XSMM torch_mlir")
232278
else:
233279
raise ValueError(f"Unsupported mode {compile_mode}")
234280

0 commit comments

Comments
 (0)