You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by JC Li via TVM Discuss <no...@discuss.tvm.ai> on 2020/05/14 09:56:44 UTC

[TVM Discuss] [Questions] Schedule not registered for 'mytarget'


I added a new 'mytarget' to target list and add dense strategy registration in python/tvm/op/strategy/mytarget.py as below:
```
@dense_strategy.register("mytarget")
def dense_strategy_mytarget(attrs, inputs, out_type, target):
    strategy = _op.OpStrategy()
    strategy.add_implementation(wrap_compute_dense(topi.nn.dense),
                                wrap_topi_schedule(topi.mytarget.schedule_dense),
                                name="dense.mytarget", 
                                plevel=20)
    return strategy
```

However, when tvm tries to select_implementations() in python/tvm/relay/backend/compile_engine.py. It always goes to the generic version of dense_strategy defined in python/tvm/op/strategy/generic.py:

```
@override_native_generic_func("dense_strategy")
def dense_strategy(attrs, inputs, out_type, target):
    """dense generic strategy"""
    logger.warning("dense is not optimized for this platform.")
    strategy = _op.OpStrategy()
    strategy.add_implementation(wrap_compute_dense(topi.nn.dense),
                                wrap_topi_schedule(topi.generic.schedule_dense),
                                name="dense.generic")
    return strategy
```

Can anyone give me some hint why my registration doesnt work? Thanks.





---
[Visit Topic](https://discuss.tvm.ai/t/schedule-not-registered-for-mytarget/6675/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/4ea9cc2d6a699ce4929a853cb325e907eeacc84768915d47f3edfb2e7a3747ca).

[TVM Discuss] [Questions] [Solved] Schedule not registered for 'mytarget'

Posted by JC Li via TVM Discuss <no...@discuss.tvm.ai>.

I finally figured it out. It was because I didn't specify "keys" when I create the new 'mytarget'. Once I add 'mytarget' as the key, the dense_strategy registration works like a charm...

It is really appreciated there'll be a tutorial/docs on how to add a new target, :slight_smile:





---
[Visit Topic](https://discuss.tvm.ai/t/solved-schedule-not-registered-for-mytarget/6675/6) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/a50704394e111b26b78b550d388f53ff9475fe3e251054c5a07407512c297500).

[TVM Discuss] [Questions] Schedule not registered for 'mytarget'

Posted by JC Li via TVM Discuss <no...@discuss.tvm.ai>.

@hht, I doubled checked, it seems the real problem might be that I declared 'mytarget' as a completely new target, instead of declaring it as a device under target 'ext_dev'.  Running 

```
print(tvm.target.Target.current(allow_none=False)
```
Shows different result. 

With VTA:
```
relay/backend/compile_engine.py: ext_dev -device=vta -keys=cpu -model=sim_1x16_i8w8a32_15_15_18_17
```
With mytaget:
```
relay/backend/compile_engine.py: mytarget
```

So is declaring a completely new target supported in TVM? If so, how different is it as adding a new device under ext_dev? Thanks.





---
[Visit Topic](https://discuss.tvm.ai/t/schedule-not-registered-for-mytarget/6675/5) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/1c87a2f31f8582728a92f028050c72da3d1124500c0a2c86ee4f25aeb88bc5a0).

[TVM Discuss] [Questions] Schedule not registered for 'mytarget'

Posted by Hanting Huang via TVM Discuss <no...@discuss.tvm.ai>.

This is where the problem lies. You need to give the target context by relay.build with the target argument.
But there is no requirement to do this in TVM for flexibility. In some tutorials, compute graph is not build by using op strategy but directly using the wrap function(cfunc&sfunc).

For example, one can build an nms graph by cfunc and sfunc without target context. And then give the target context in building stage.
```
out = topi.vision.nms.non_max_suppression(data, valid_count, iou_threshold=iou_threshold,
                                force_suppress=force_suppress, top_k=top_k)
s = topi.generic.schedule_nms(out)
print(tvm.lower(s,[data,valid_count,out]))
f = tvm.build(s, [data, valid_count, out],  "llvm")
```





---
[Visit Topic](https://discuss.tvm.ai/t/schedule-not-registered-for-mytarget/6675/4) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/7e7429c3e491205679c3564c7e0bed83bc8aa4340ad40e09b0efc417cc51bc0f).

[TVM Discuss] [Questions] Schedule not registered for 'mytarget'

Posted by JC Li via TVM Discuss <no...@discuss.tvm.ai>.

Thank you, @hht . It seems my target isn't constructed appropriately. But why it doesn't complain anything in the run before?

```
  File "relay_linearnet.py", line 32, in <module>
    print(tvm.target.Target.current(allow_none=False))

  File "/work/git_repo/tvm/python/tvm/target/target.py", line 103, in current
    return _ffi_api.GetCurrentTarget(allow_none)

  File "tvm/_ffi/_cython/./packed_func.pxi", line 308, in tvm._ffi._cy3.core.PackedFuncBase.__call__

  File "tvm/_ffi/_cython/./packed_func.pxi", line 243, in tvm._ffi._cy3.core.FuncCall

  File "tvm/_ffi/_cython/./packed_func.pxi", line 232, in tvm._ffi._cy3.core.FuncCall3

  File "tvm/_ffi/_cython/./base.pxi", line 159, in tvm._ffi._cy3.core.CALL

tvm._ffi.base.TVMError: Traceback (most recent call last):
  [bt] (6) /work/git_repo/tvm/build/libtvm.so(TVMFuncCall+0x95) [0x7f39251155b6]
  [bt] (5) /work/git_repo/tvm/build/libtvm.so(tvm::runtime::PackedFunc::CallPacked(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const+0x30) [0x7f39246d655e]
  [bt] (4) /work/git_repo/tvm/build/libtvm.so(std::function<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const+0x5a) [0x7f39246d6baa]
  [bt] (3) /work/git_repo/tvm/build/libtvm.so(+0x31a7fd4) [0x7f3924ac3fd4]
  [bt] (2) /work/git_repo/tvm/build/libtvm.so(+0x31a5f5d) [0x7f3924ac1f5d]
  [bt] (1) /work/git_repo/tvm/build/libtvm.so(tvm::Target::Current(bool)+0xec) [0x7f3924ac1eb2]
  [bt] (0) /work/git_repo/tvm/build/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x4a) [0x7f3924575370]
  File "/work/git_repo/tvm/src/target/target.cc", line 269
TVMError: Check failed: allow_not_defined: Target context required. Please set it by constructing a TargetContext
```





---
[Visit Topic](https://discuss.tvm.ai/t/schedule-not-registered-for-mytarget/6675/3) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/1da4e5757fff4befb8db4aa227622e16ab082ef332b26ce0449d2d00ef312ee7).

[TVM Discuss] [Questions] Schedule not registered for 'mytarget'

Posted by Hanting Huang via TVM Discuss <no...@discuss.tvm.ai>.

It seems right. Maybe your target is error. Use this to see your current target.
```
print(tvm.target.Target.current(allow_none=False)
```





---
[Visit Topic](https://discuss.tvm.ai/t/schedule-not-registered-for-mytarget/6675/2) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/d4c3bbc2fc94c0aa726e5a8dc57e0f6b56704890a0a2e32654d74378cec6264f).