You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/03/23 00:05:03 UTC

[GitHub] [incubator-tvm] Laurawly commented on issue #5116: Add thrust support for nms

Laurawly commented on issue #5116: Add thrust support for nms
URL: https://github.com/apache/incubator-tvm/pull/5116#issuecomment-602302249
 
 
   > @Laurawly Can we have implementation like this? Big if/else blocks should be put inside ` thrust_sort_common`.
   > 
   > ```
   > TVM_REGISTER_GLOBAL("tvm.contrib.thrust.sort")
   > .set_body([](TVMArgs args, TVMRetValue* ret) {
   >   CHECK_GE(args.num_args, 5);
   >   DLTensor* input = args[0];
   >   DLTensor* valid_count = args[1];
   >   DLTensor* values_out = args[2];
   >   DLTensor* indices_out = args[3];
   >   bool is_ascend = args[4];
   > 
   >   auto data_dtype = DLDataType2String(input->dtype);
   >   auto out_dtype = DLDataType2String(indices_out->dtype);
   > 
   >   int n_values = input->shape[input->ndim - 1];
   >   auto get_sort_len = [=](int i) { return n_values; };
   >   thrust_sort_common(input, values_out, indices_out, is_ascend, get_sort_len, data_type, out_dtype);
   > }
   > 
   > TVM_REGISTER_GLOBAL("tvm.contrib.thrust.sort_nms")
   > .set_body([](TVMArgs args, TVMRetValue* ret) {
   >   CHECK_GE(args.num_args, 5);
   >   DLTensor* input = args[0];
   >   DLTensor* valid_count = args[1];
   >   DLTensor* values_out = args[2];
   >   DLTensor* indices_out = args[3];
   >   bool is_ascend = args[4];
   > 
   >   auto data_dtype = DLDataType2String(input->dtype);
   >   auto out_dtype = DLDataType2String(indices_out->dtype);
   > 
   >   thrust::device_ptr<IndicesType> valid_count_ptr(static_cast<IndicesType *>(valid_count->data));
   >   auto get_sort_len = [&valid_count_ptr](int i) { return valid_count_ptr[i] };
   >   thrust_sort_common(input, values_out, indices_out, is_ascend, get_sort_len, data_type, out_dtype);
   > }
   > ```
   
   Lemme know if the changes look good to you.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services