TypeError: 'Tensor' object does not support item assignment

Hi all, I’m trying to write a anonymous function of tensor computation for avg_pool gradient using tvm.compute(), which involves tensor self-add in the anonymous function, while it occurs error when i did this, log:

TypeError: ‘Tensor’ object does not support item assignment

dout = ...
batch, in_channel, in_height, in_width = Input.shape
stride_h, stride_w = stride[0], stride[1]
pool_h, pool_w = pool_size[0], pool_size[1]
pad_top, pad_left, pad_down, pad_right = padding...

out_height = simplify((in_height - pool_h + pad_top + pad_down) // stride_h + 1)
out_width = simplify((in_width - pool_w + pad_left + pad_right) // stride_w + 1)

pad_before = [0, 0, pad_top, pad_left]
pad_after = [0, 0, pad_down, pad_right]
temp = pad(Input, pad_before, pad_after, name="pad_temp")

rh = tvm.reduce_**strong text**axis((0, pool_h), name='rh')
rw = tvm.reduce_axis((0, pool_w), name='rw')

divide_factor = ...
dinput = relay.zeros_like()
def bp_pool(batch, channel, h, w):
    dinput[batch, channel, rh + h, rw + w] += dout[batch, channel, h, w]/divide_factor
     ...

res = tvm.compute((batch, in_channel, out_height, out_width), lambda nn, cc, yy, xx: bp_bool(nn, cc, yy, xx), )

@jroesch, @altanh, I saw you discussed gradient in here, could you please help me, and any idea how to solve this issue?
Thanks.

1 Like