You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tvm.apache.org by Yuke Wang via Apache TVM Discuss <no...@discuss.tvm.ai> on 2022/01/06 22:13:19 UTC

[Apache TVM Discuss] [Development] BYOC CodeGen for customized Call Node/Operator


Hi, All

If I want to use BYOC for a new operator, should I skip the Step 4-5 in this tutorial https://tvm.apache.org/docs/dev/how_to/relay_add_op.html?

Thanks!





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-codegen-for-customized-call-node-operator/11863/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/418dda152f8feab07651355d5b8cc3cbf2b9ffdb39e573e1dc637bd754f0188a).

[Apache TVM Discuss] [Development] BYOC CodeGen for customized Call Node/Operator

Posted by Yuke Wang via Apache TVM Discuss <no...@discuss.tvm.ai>.

When I remove those strategy statement for my customize operator at `generic.py` and `cuda.py`, I encounter a problem like
```
AttributeError: module 'tvm.relay.op.strategy' has no attribute 'myop_strategy'
```
is there any workaround to avoid such check?





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-codegen-for-customized-call-node-operator/11863/8) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/09cf1db3855ce807c45ce136eb89d8beb5a32b8c902587df65e6379be8949021).

[Apache TVM Discuss] [Development] BYOC CodeGen for customized Call Node/Operator

Posted by Yuke Wang via Apache TVM Discuss <no...@discuss.tvm.ai>.

How to specify my customized codegen when building the model? For example, my customized codegen will generate CUDA kernel code and the host code, should I still keep the `target='cuda'`?





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-codegen-for-customized-call-node-operator/11863/9) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/39dc3e35eaaaed0fcb6f16b544404a9743c2ae305f9d6912f0fc9ed6c2a42b04).

[Apache TVM Discuss] [Development] BYOC CodeGen for customized Call Node/Operator

Posted by masahi via Apache TVM Discuss <no...@discuss.tvm.ai>.

You shouldn't need to deal with strategy stuff for operators offloaded to BYOC.





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-codegen-for-customized-call-node-operator/11863/7) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/2fb1b31ef2cc0edb29b33366ebb833e54247c29340fae251edb69cf991b60aa8).

[Apache TVM Discuss] [Development] BYOC CodeGen for customized Call Node/Operator

Posted by Yuke Wang via Apache TVM Discuss <no...@discuss.tvm.ai>.

this problem solved due to mismatched `set_body_typed(MakeFun)` and the actual `MakeFun`





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-codegen-for-customized-call-node-operator/11863/4) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/68954170391d4f3342113dd4e99948fa8468138fd0b4aeb782996bf7f1ae408e).

[Apache TVM Discuss] [Development] BYOC CodeGen for customized Call Node/Operator

Posted by Yuke Wang via Apache TVM Discuss <no...@discuss.tvm.ai>.

I just encounter a problem that 

```
Check failed: (!actual_type.defined()) is false: Expected type PrimExpr but got relay.Var
```
Even though  my new operator defined with 
```
Expr MakeFun(Expr X1, Expr X2, Expr X3, DataType out_dtype) 
```
My type relation function is written as 
```
bool FunRel(const Array<Type>& types, int num_inputs, const Attrs& attrs,
                 const TypeReporter& reporter) {
      CHECK_EQ(types.size(), 4);                 
      ​reporter->Assign(types[3], type[0]);
      return true;
}
```
I just want the output type match the type of the first input (X1).





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-codegen-for-customized-call-node-operator/11863/3) to respond.

You are receiving this because you enabled mailing list mode.

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

[Apache TVM Discuss] [Development] BYOC CodeGen for customized Call Node/Operator

Posted by Yuke Wang via Apache TVM Discuss <no...@discuss.tvm.ai>.

Now I counter another problem
```
nn.func doesn't have an FTVMStrategy registered. You can register one in python with `tvm.relay.op.register_strategy`.
```
Should I put some dummy strategy for this operator even if I use BYOC?





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-codegen-for-customized-call-node-operator/11863/5) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/15b1cc4b63902ae09ddc0eebf0d82baa4235b01c9177faf23526a9913e407da9).

[Apache TVM Discuss] [Development] BYOC CodeGen for customized Call Node/Operator

Posted by Yuke Wang via Apache TVM Discuss <no...@discuss.tvm.ai>.

Hi, how should I set the add_implementation function at the Relay frontend when I decide to use BYOC? Since I will not use the operator from `topi`
```
@override_native_generic_func("cumprod_strategy")
def cumprod_strategy(attrs, inputs, out_type, target):
    """cumprod generic strategy"""
    strategy = _op.OpStrategy()
    strategy.add_implementation(
        wrap_compute_scanop(topi.cumprod),
        wrap_topi_schedule(topi.generic.schedule_extern),
        name="cumprod.generic",
    )
    return strategy

@cumsum_strategy.register(["cuda", "gpu"])
def cumsum_strategy_cuda(attrs, inputs, out_type, target):
    """cumsum cuda strategy"""
    strategy = _op.OpStrategy()
    strategy.add_implementation(
        wrap_compute_scanop(topi.cuda.cumsum),
        wrap_topi_schedule(topi.cuda.schedule_scan),
        name="cumsum.cuda",
    )
    return strategy
```





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-codegen-for-customized-call-node-operator/11863/6) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/42c9d16cb46159cc06312cf7a77fa4cb9b202fb25436837f47a3f148ff1a3f5b).

[Apache TVM Discuss] [Development] BYOC CodeGen for customized Call Node/Operator

Posted by masahi via Apache TVM Discuss <no...@discuss.tvm.ai>.

Yes, if you don't intend to compile your model with native tvm, you only need relay op so can skip that steps.





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-codegen-for-customized-call-node-operator/11863/2) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/518e62f0924bb9d98c8018c653cf526a756c6b5cb5d95221b5adac79715fe51f).