FrozenGene edited a comment on pull request #5914:
URL: https://github.com/apache/incubator-tvm/pull/5914#issuecomment-651708824


   > How about we go with A1 for now, @FrozenGene can you update this PR to A1?
   
   @tqchen If we use
    ```python
   # cache flush packed is a packed func that performs the cpu cache flush
   cache_flush_packed = remote.get_function("cpu_cache_flush")(args=begin=1)
   # fprepare is a callback that will be called before the evaluation, it takes 
in args as arguments. 
   f = mod.time_evaluator("myfunc", repeat=10, fprepare=cache_flush_packed)
   ```
   We will meet `Cannot pass type FunctionHandle as an argument to the remote` 
error. Do you have any good suggestion about it?
   
   Related Code (see `Wrong` and `Pass` part):
   ```c++
   TVM_REGISTER_GLOBAL("runtime.RPCTimeEvaluator")
       .set_body_typed([](Optional<Module> opt_mod, std::string name, int 
device_type, int device_id,
                          int number, int repeat, int min_repeat_ms, PackedFunc 
f_prepare) {
         TVMContext ctx;
         ctx.device_type = static_cast<DLDeviceType>(device_type);
         ctx.device_id = device_id;
         if (opt_mod.defined()) {
           Module m = opt_mod.value();
           std::string tkey = m->type_key();
           if (tkey == "rpc") {
             // Wrong
             return static_cast<RPCModuleNode*>(m.operator->())
                 ->GetTimeEvaluator(name, ctx, number, repeat, min_repeat_ms, 
f_prepare);
             // Pass
             ctx.device_type = static_cast<DLDeviceType>(ctx.device_type % 
kRPCSessMask);
             return WrapTimeEvaluator(m.GetFunction(name, false), ctx, number, 
repeat, min_repeat_ms, f_prepare);
           } else {
             return WrapTimeEvaluator(m.GetFunction(name, false), ctx, number, 
repeat, min_repeat_ms, f_prepare);
           }
         }
   ```


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to