# TVM code generation has redundant border?

**URL:** <https://discuss.tvm.apache.org/t/tvm-code-generation-has-redundant-border/4334>\
**Category:** Troubleshooting\
**Created:** [October 15, 2019, 8:33am UTC](https://discuss.tvm.apache.org/t/tvm-code-generation-has-redundant-border/4334 "2019-10-15T08:33:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snowolfhawk](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/s/e495f1/32.png) [@snowolfhawk](https://discuss.tvm.apache.org/u/snowolfhawk)\
**Post date:** [October 15, 2019, 8:33am UTC](https://discuss.tvm.apache.org/t/tvm-code-generation-has-redundant-border/4334/1 "2019-10-15T08:33:37Z")

</div>

Using the below tvm code:  
A = tvm.placeholder((1080, 1920), name=‘A’, dtype=dtype)  
K = tvm.placeholder((3, 3), name=‘K’, dtype=dtype)  
ry = tvm.reduce\_axis((0, 3), name=‘ry’)  
rx = tvm.reduce\_axis((0, 3), name=‘rx’)

C = tvm.compute((1080-2, 1920-2), lambda i, j: tvm.sum((A[i + ry, j + rx] \*K[ry, rx]), axis=[ry, rx]), name=‘C’)  
print(“C shape:”, C.shape)

pad\_before = [1, 1]  
pad\_after = [1, 1]  
F = topi.nn.pad(C, pad\_before, pad\_after, name=“pad\_F”)  
print(“F shape:”, F.shape)

s = tvm.create\_schedule(F.op)  
print(tvm.lower(s, [A, K, C, F], simple\_mode=True))

The print IR code is:

```
C shape: [1078, 1918]
F shape: [1080, 1920]
produce C {
for (i, 0, 1080) {
	for (j, 0, 1920) {
		C[(((i1918) + j) + -1919)] = 0.000000f
		for (ry, 0, 3) {
			for (rx, 0, 3) {
				if (likely((1 <= i))) {
				if (likely((i < 1079))) {
				if (likely((1 <= j))) {
				if (likely((j < 1919))) {
					C[(((i1918) + j) + -1919)] = (C[(((i1918) + j) + -1919)] + (A[(((((i + ry)1920) + j) + rx) + -1921)]K[((ry3) + rx)]))
				}
				}
				}
				}
			}
		}
	}
}
}
produce pad_F {
for (i0, 0, 1080) {
	for (i1, 0, 1920) {
		ad_F[((i01920) + i1)] = tvm_if_then_else(((((1 <= i0) && (i0 < 1079)) && (1 <= i1)) && (i1 < 1919)), C[(((i0*1918) + i1) + -1919)], 0.000000f)
	}
}
}

```

The C shape is [1078, 1918], Why the i and j axis of product C’s range is (0, 1080) and (0,1920)?

---

<div class="post-metadata">

**Author:** ![aca88](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@aca88](https://discuss.tvm.apache.org/u/aca88)\
**Post date:** [November 22, 2019, 10:54am UTC](https://discuss.tvm.apache.org/t/tvm-code-generation-has-redundant-border/4334/2 "2019-11-22T10:54:30Z")

</div>

Hey, I am not 100% sure but maybe if you look in this post you will see what might be the cause.

> **[\[TVM Scheduling\] Split factors missmatch to original extent](https://discuss.tvm.apache.org/t/tvm-scheduling-split-factors-missmatch-to-original-extent/2982)**
>
> Hello all, I have been confronted with a problem that I am unsure how to solve and therefore thought to ask the community. Hopefully the problem is not so trivial 🙂 We know that using...

Even though the linked post is old and I think there wasn’t a definite answer, the `schedule.normalize()` will bring all the loops to a common representation (in this case since C can be embedded in the iteration space of F, the boundaries are those of F)
