nod-ai / SHARK-Turbine

Unified compiler/runtime for interfacing with PyTorch Dynamo.
Apache License 2.0
82 stars 41 forks source link

examples/resnet-18 compilation error #506

Open Peter9606 opened 4 months ago

Peter9606 commented 4 months ago

Hi,

Can example Resnet-18 run on CUDA ? I'm asking this for I got following error while trying to run Resnet-18 example with modifying target_backends to "cuda".


    %5 = torch.aten.convolution %arg0, %0, %none, %1, %2, %3, %false, %4, %int1_4 : !torch.vtensor<[?,3,224,224],f32>, !torch.vtensor<[64,3,7,7],f32>, !torch.none, !torch.list<int>, !torch.list<int>, !torch.list<int>, !torch.bool, !torch.list<int>, !torch.int -> !torch.vtensor<[?,64,112,112],f32>
         ^
module.mlir:66:10: note: called from
    %1 = call @forward$1(%0) : (!torch.vtensor<[?,3,224,224],f32>) -> !torch.vtensor<[?],si64>```
ScottTodd commented 4 months ago

Can you share more context about what went wrong (specific error message + surrounding context)? Also, can you be more specific about what you tried to do (which Resnet-18 example, at what point did it fail, etc.)?

yujc9 commented 4 months ago

We (Peter and I) use the case: SHARK-Turbine/core/examples/resnet-18/resnet-18.py, and change it to cuda backend:

diff --git a/core/examples/resnet-18/resnet-18.py b/core/examples/resnet-18/resnet-18.py index 2034001..635ac9a 100644 --- a/core/examples/resnet-18/resnet-18.py +++ b/core/examples/resnet-18/resnet-18.py @@ -31,14 +31,17 @@ class RN18(CompiledModule):

exported = export(RN18) +#exported.print_readable() ... -compiled_binary = exported.compile(save_to=None) +#compiled_binary = exported.compile(save_to=None) +compiled_binary = exported.compile(save_to=None, target_backends="cuda") ... def shark_infer(x):

Then, we got a runtime error in exporter.py: raise RuntimeError("Compilation failed: See diagnostics") RuntimeError: Compilation failed: See diagnostics So, we dump the .mlir (by enabling model.print_readable()) and compile it with iree-compile finding some errors. One of them are 'scf.for' op upper bound should be a constant.