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 "Cody H. Yu via Apache TVM Discuss" <no...@discuss.tvm.ai> on 2022/03/01 18:00:57 UTC

[Apache TVM Discuss] [Questions] [BYOC] details about BYOC (newbie)


1. Yes, because the codegen is now a part of TVM shared library. However, cmake with ccache should save your time for unchanged files.
2. As the document indicates, you should apply a series of passes from AnnotateTarget to PartitionGraph. After that, you could print the IR to see if there's any Relay function with attribute `kCopiler="your-codegen-name"`. If so, then your codegen will be used when calling `relay.build`.
3. Yes.
4. As you already answered.
5. I don't understand this question, but a Relay program must have an output, and you cannot print message inside the Relay function. The error you got is a misuse. You should still use `llvm` as the target, which is the target for "non-offloaded" parts of the model. Again, as long as your IR includes function with `kCompiler=your-codegen-name`, then it will be offloaded to your codegen whatever the target you specify.





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-details-about-byoc-newbie/12190/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/fe9d9253e5a12978ac22fd3e4ff428d238b09304d5d0a05ebd67d08dc99e6bdf).

[Apache TVM Discuss] [Questions] [BYOC] details about BYOC (newbie)

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

Right, that was my initial thoughts.

Although my intial question was: *can the generated code not bother about filling the output tensor with some values?*
But I realise that the question is a stupid as `out` is already allocated, whether its content is relevant or not shouldn't create any major bug when playing.

To illustrate what I meant, let's say in the documentation example I replace the macros to:
```
#define CSOURCE_BINARY_OP_1D(p_ID_, p_OP_, p_DIM1_)         \
    extern "C" void p_ID_(float* a, float* b, float* out) { \
        printf("I am calling a 1D op\n");                           \
    }
```

> As the document indicates, you should apply a series of passes from AnnotateTarget to PartitionGraph. 

I think everything starts to connect now, to recap (correct me if I am wrong):

I need to write `python/tvm/relay/op/contrib/{CODEGEN_NAME}.py` to tell tvm how to partition my graph for my codegen. 
The bare minimum this file should contain is:
* registering external op used by my codegen
* defining a function with the name `partition_for_{CODEGEN_NAME}(mod, params=None)` that applies transformations to `mod`, including at least:
   1. `AnnotateTarget("{CODEGEN_NAME"})`
   2. `PartitionGraph()`

If I have correctly built tvm with my codegen and have provided the mentionned python file then when building for llvm target tvm will automatically use the `partition_for_{MY_CODEGEN}` function.





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-details-about-byoc-newbie/12190/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/703801d3daab604b5aca4fa42d76a2df9353d3b04f605356447aa76932d33c81).

[Apache TVM Discuss] [Questions] [BYOC] details about BYOC (newbie)

Posted by "Cody H. Yu via Apache TVM Discuss" <no...@discuss.tvm.ai>.

In the BYOC case you can control everything in your generated code. The runtime only in charges of invoking the partitioned function on CPU by its name (i.e., symbol), so you could do anything you want. In short, it's doable to generate/compile a C function with side effects and run it on a supported device.





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-details-about-byoc-newbie/12190/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/3a7bf72636a4b4b63cbd69fceddbc14975d055d016387d6a5d628d93ae0524a7).

[Apache TVM Discuss] [Questions] [BYOC] details about BYOC (newbie)

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

Thank you for answering. this helps quite a bit.

> I don’t understand this question, but a Relay program must have an output, and you cannot print message inside the Relay function.

Let's say for a a `relay.nn.conv2d` function, we produce a C function that prints some information. The motivation for this is to get confident with the BYOC framework before getting into more serious work.

So  we can't generate functions that prints a message (or have side effects)? Can we call an external library that has side effects?

I guess it is always possible to fill the output tensor with dummy values, but if it isn't possible to print a message then my question loses its purpose.





---
[Visit Topic](https://discuss.tvm.apache.org/t/byoc-details-about-byoc-newbie/12190/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/ccddb78e9d278189d767e56f4ca600895589cc9f28e9ba89976b3a50ff915e15).