# [Hybrid script]Check failed: allow_alloc == false: Cannot find the Realization point of tensor Tensor(shape=[1, 6, 14, 14], op.name=PaddedData)

I’m a beginner and am learning hybrid tutorial,so I want to implement a conv2d using tvm.te.hybrid.script.Here is my snippet:

``````import tvm
from tvm import te
from tvm.te.hybrid import script
import numpy as np
@script
def Conv2D(data,conv1_weight):
#s=0.000000
conv1 = output_tensor((1,4,12,12),"float32")
for n in range(1):
for i0 in range(6):
for i1 in range(14):
for i2 in range(14):
PaddedData[n,i0,i1,i2] = 0.000000 if i1<1 or 1+12<=i1 or i2<1 or 1+12<=i2 else data[n,i0,i1-1,i2-1]
for n in range(1):
for c in range(4):
for i in range(12):
for j in range(12):
conv1[n,c,i,j] = 0.000000
for ric in range(6):
for rkh in range(3):
for rkw in range(3):
#s = 0.000000 if i+rkh<1 or 1+12<=i+rkh or j+rkw<1 or 1+12<=j+rkw else data[n,ric,i+rkh-1,j+rkw-1]
#conv1[n,c,i,j] = conv1[n,c,i,j]+ s*conv1_weight[c,ric,rkh,rkw]
conv1[n,c,i,j] = conv1[n,c,i,j]+ PaddedData[n,ric,i*1+rkh,j*1+rkw]*conv1_weight[c,ric,rkh,rkw]
return conv1
data = te.placeholder(shape=(1,6,12,12),name="data",dtype="float32")
conv1_weight = te.placeholder(shape=(4,6,3,3),name="conv1_weight",dtype="float32")
res = Conv2D(data,conv1_weight)
sch = te.create_schedule(res.op)
mod = tvm.build(sch,(data,conv1_weight,res))
``````

conv2d parameters : data[1,6,12,12] conv1_weight[4,6,3,3] with stride=1 and padding=1 My implementation is firstly implementing PaddedData part then conv1 part,but an error occured as below:

``````CRITICAL:root:[Warning] Not all the output buffers returned!
Traceback (most recent call last):
File "conv2d.py", line 31, in <module>
mod = tvm.build(sch,(data,conv1_weight,res))
input_mod = lower(inputs, args, name=name, binds=binds)
mod = form_irmodule(sch, args, name, binds)
func = schedule.SchedulePostProcToPrimFunc(arg_list, stmt, binds)
File "tvm/_ffi/_cython/./packed_func.pxi", line 322, in tvm._ffi._cy3.core.PackedFuncBase.__call__
File "tvm/_ffi/_cython/./packed_func.pxi", line 257, in tvm._ffi._cy3.core.FuncCall
File "tvm/_ffi/_cython/./packed_func.pxi", line 246, in tvm._ffi._cy3.core.FuncCall3
File "tvm/_ffi/_cython/./base.pxi", line 160, in tvm._ffi._cy3.core.CALL
tvm._ffi.base.TVMError: Traceback (most recent call last):
[bt] (8) /home/sun/gitDownload/tvm/build/libtvm.so(tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>::VisitStmt(tvm::tir::Stmt const&)+0x85) [0x7fd727597015]
[bt] (7) /home/sun/gitDownload/tvm/build/libtvm.so(tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>::InitVTable()::{lambda(tvm::runtime::ObjectRef const&, tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>*)#4}::_FUN(tvm::runtime::ObjectRef const&, tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>*)+0x27) [0x7fd72758c467]
[bt] (4) /home/sun/gitDownload/tvm/build/libtvm.so(tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>::VisitStmt(tvm::tir::Stmt const&)+0x85) [0x7fd727597015]
[bt] (3) /home/sun/gitDownload/tvm/build/libtvm.so(tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>::InitVTable()::{lambda(tvm::runtime::ObjectRef const&, tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>*)#8}::_FUN(tvm::runtime::ObjectRef const&, tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>*)+0x27) [0x7fd72758c5a7]
TVMError:
---------------------------------------------------------------
An internal invariant was violated during the execution of TVM.
This error message is telling you the problem. Because `PaddedData` is an output_tensor, it needs to be returned from the function. Alternatively, you can use `allocate` to create an intermediate buffer. You can look at `tests/python/unittest/test_te_hybrid_script.py` for examples.