Error when using topi for convolution

Ive encountered this error when trying to use a convolution operation using tvm

This is the code

from future import absolute_import, print_function

import tvm from tvm import te from tvm import topi import numpy as np

np.random.seed(1)

data = te.placeholder((1, 3, 32, 32), name=“data”) kernel = te.placeholder((1, 3, 5, 5), name=“kernel”)

conv = topi.cuda.conv2d_nchw(data, kernel, 1, 0, 0) out = topi.nn.relu(conv)

with tvm.target.create(“opencl”) :

sconv = topi.cuda.schedule_conv2d_nchw([conv])
print(tvm.lower(sconv, [data, kernel], simple_mode=True))

func = tvm.build(sconv, [data, kernel], ‘opencl’) ctx = tvm.opencl(0)

image = np.random.uniform(size=(1, 3, 32, 32)).astype(data.dtype) filter = np.random.uniform(size=(1, 3, 5, 5)).astype(kernel.dtype) image = tvm.nd.array(image, ctx) filter = tvm.nd.array(filter, ctx)

final_out = tvm.nd.array(np.zeros((1,1, 32, 32), dtype=image.dtype), ctx) func(image, filter) print(final_out)

and this is the error generated

Cannot find config for target=None, workload=(‘conv2d_nchw.cuda’, (‘TENSOR’, (1, 3, 32, 32), ‘float32’), (‘TENSOR’, (1, 3, 5, 5), ‘float32’), 1, 0, 0). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=opencl -keys=opencl,gpu -max_num_threads=256, workload=(‘conv2d_nchw.cuda’, (‘TENSOR’, (1, 3, 32, 32), ‘float32’), (‘TENSOR’, (1, 3, 5, 5), ‘float32’), 1, 0, 0). A fallback configuration is used, which may bring great performance regression.

Traceback (most recent call last): File “topi_code_CNN.py”, line 29, in func(image, filter, final_out) File “/home/akhil/Downloads/TVM/tvm/python/tvm/runtime/module.py”, line 110, in call return self.entry_func(*args) File “/home/akhil/Downloads/TVM/tvm/python/tvm/_ffi/_ctypes/packed_func.py”, line 225, in call raise get_last_ffi_error() tvm._ffi.base.TVMError: Traceback (most recent call last): [bt] (2) /home/akhil/Downloads/TVM/tvm/build/libtvm.so(TVMFuncCall+0x65) [0x7fa5749cce55] [bt] (1) /home/akhil/Downloads/TVM/tvm/build/libtvm.so(+0x1672cf0) [0x7fa5749e1cf0] [bt] (0) /home/akhil/Downloads/TVM/tvm/build/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x82) [0x7fa573fd4862] File “/home/akhil/Downloads/TVM/tvm/src/runtime/opencl/opencl_module.cc”, line 220 File “/home/akhil/Downloads/TVM/tvm/src/runtime/library_module.cc”, line 78 TVMError: Check failed: ret == 0 (-1 vs. 0) : OpenCL build error for device=0x7fa56fa500c0stringInput.cl:1:94: error: expected ‘)’ stringInput.cl:1:39: note: to match this ‘(’ stringInput.cl:1:94: error: parameter name omitted stringInput.cl:17:71: error: expected expression stringInput.cl:27:21: error: use of undeclared identifier ‘compute’ stringInput.cl:28:21: error: use of undeclared identifier ‘compute’ stringInput.cl:29:21: error: use of undeclared identifier ‘compute’ stringInput.cl:30:21: error: use of undeclared identifier ‘compute’

1 Like