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 Luca Fancellu via Apache TVM Discuss <no...@discuss.tvm.ai> on 2020/09/09 07:59:47 UTC

[Apache TVM Discuss] [Questions] Use cuda pointers with TVM


Hi everybody, 
I'm trying to use TVM on a C++ project to remove a tensorRT dependency.

This project uses cuda code to process data and puts the result on cuda arrays that in the original code are feed to the tensorRT inference engine.
I would like to use these arrays converted as DLTensor as input of my TVM network.

Is there a way to convert a cuda arrays to DLTensor? I'm new approaching TVM so sorry if this seems a dumb question, I've searched on this forum but I can't find the answer.

Thank you





---
[Visit Topic](https://discuss.tvm.apache.org/t/use-cuda-pointers-with-tvm/7853/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/d9fc73aa9f13098cdfdbab608df7510a394fed4d214e802851d78da11b570252).

[Apache TVM Discuss] [Questions] Use cuda pointers with TVM

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

So can I simply do that?

    void* ptr;
    cudaMalloc(&ptr, 10 * 10 * 2 * sizeof(float));
    TVMArray *x{};
    std::vector<int64_t> shape ={1, 10, 10, 2};
    TVMArrayAlloc(&shape[0], shape.size(), kDLFloat, 32, 1, kDLGPU, 0, &x);
    x->data = ptr;





---
[Visit Topic](https://discuss.tvm.apache.org/t/use-cuda-pointers-with-tvm/7853/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/20162c98264f52b829ae2c1edf098864cdedadd873c0dc8b9c090c09b1e31d9b).

[Apache TVM Discuss] [Questions] Use cuda pointers with TVM

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

It is possible and straightforward to convert a cuda array to DLTensor. Just set the `DLTensor::data` to the cuda array, `DLTensor::ctx` to be (kDLGPU, 0), and other fields too accordingly. If you have specific questions about a field, feel free to ask :-)





---
[Visit Topic](https://discuss.tvm.apache.org/t/use-cuda-pointers-with-tvm/7853/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/4bd7cc69ebe93173f24a7ceb2675a3ad6c0329e505002433a2cdb8028434c277).