echuraev commented on issue #8700:
URL: https://github.com/apache/tvm/issues/8700#issuecomment-904706891


   Hello @schell!
   
   I took a look at your problem and I'm not able to reproduce the issue. I 
tried on Apple M1 and x86. And on both machines everything works fine. Could 
you please provide more details about your problem? Maybe some simple scripts 
which reproduces the issue or something like that?
   
   I used the following simple script for running some simple model on metal:
   ```python
   import numpy as np
   import math
   
   import os
   import tvm
   from tvm import relay, auto_scheduler
   from tvm import testing
   from tvm.contrib import utils, xcode, coreml_runtime, graph_runtime
   
   target = "metal"
   target_host = "llvm -mtriple=arm64-apple-darwin20.5.0"
   
   
   def _get_model(shape, dtype, var_names):
       """Return a model and any parameters it may have."""
       a = relay.var(next(var_names), shape=shape, dtype=dtype)
       out = relay.op.reduce.mean(a, 0)
       params = {}
       return out, params
   
   
   def converter(shape):
       print("Shape: {}".format(shape))
       dtype = "float32"
       # b, data
       inputs = {"data": tvm.nd.array(np.random.uniform(-128, 127, 
shape).astype(dtype))}
       mod, params = _get_model(shape, dtype, iter(inputs))
       if isinstance(mod, tvm.relay.expr.Call):
           mod = tvm.IRModule.from_expr(mod)
       print('mod: ', mod)
       with tvm.transform.PassContext(opt_level=3):
           graph_module = relay.build(mod['main'], target=target, 
target_host=target_host, params=params)
       #with auto_scheduler.ApplyHistoryBest("my_mean_model_metal"):
       #    with tvm.transform.PassContext(opt_level=3, 
config={"relay.backend.use_auto_scheduler": True}):
       #        graph_module = relay.build(mod['main'], target=target, 
target_host=target_host, params=params)
       return graph_module
   
   
   def run(graph_module):
       ctx = tvm.metal(0)
       m = 
graph_runtime.graph_executor.GraphModule(graph_module["default"](ctx))
       m.run()
   
   
   if __name__ == "__main__":
       shape = (2, 1)
       gm = converter(shape)
       run(gm)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to