# \[AutoTVM\] CUDA runtime error when tuning extern ops

**URL:** <https://discuss.tvm.apache.org/t/autotvm-cuda-runtime-error-when-tuning-extern-ops/8832>\
**Category:** Questions\
**Created:** [January 11, 2021, 4:55am UTC](https://discuss.tvm.apache.org/t/autotvm-cuda-runtime-error-when-tuning-extern-ops/8832 "2021-01-11T04:55:33Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![masahi](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/masahi/32/74_2.png) [@masahi](https://discuss.tvm.apache.org/u/masahi)\
**Post date:** [January 18, 2021, 9:00am UTC](https://discuss.tvm.apache.org/t/autotvm-cuda-runtime-error-when-tuning-extern-ops/8832/7 "2021-01-18T09:00:45Z")

</div>

@comaniac @FrozenGene @merrymercy

I figured out what’s going on. The issue is `random_fill` function used by AutoTVM:

> <https://github.com/apache/tvm/blob/23bd82596f57c66adbd01bcb88f19209995d586c/python/tvm/auto_scheduler/measure.py#L765>

I’m trying to tune `scatter` op, which has an integer input as one of inputs. This poses two problems for `random_fill`.

1. `random_fill` implementation is busted if the input is 32 or 64 bit integer tensor, see

> <https://github.com/apache/tvm/blob/1831c17998b29f3797f364410980809bfef554ca/src/runtime/contrib/random/mt_random_engine.cc#L150-L154>

As a result of this, the index tensor is filled with values like

```auto
array([1091617754, 1090832347, 1091032493, ..., 1084215127, 1073655395,
       1090813385], dtype=int32

```

1. The value of index tensor cannot be any random values, since the entry is the index into the scattered tensor. In our relay test for example, the index tensor is initialized as follows:

> <https://github.com/apache/tvm/blob/466383a232097b5c17733e347c2cb4a8ba14d972/tests/python/relay/test_op_level3.py#L965>

How should we solve this issue? I think I’ll simply skip the random init when the workload is from `scatter` op.

---

_[View the full topic](https://discuss.tvm.apache.org/t/autotvm-cuda-runtime-error-when-tuning-extern-ops/8832)._
