From 2d9bc7512464ce9ec70f2237974cc229ab4feb0c Mon Sep 17 00:00:00 2001
From: Wei Chen <ipondering.weic@gmail.com>
Date: Sun, 14 Oct 2018 15:37:28 -0700
Subject: [PATCH] Add test to confirm that we forbid allocate statement
 referencing undefined variable (#1899)

---
 .../unittest/test_pass_split_host_device.py     | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 tests/python/unittest/test_pass_split_host_device.py

diff --git a/tests/python/unittest/test_pass_split_host_device.py b/tests/python/unittest/test_pass_split_host_device.py
new file mode 100644
index 000000000..24cc49794
--- /dev/null
+++ b/tests/python/unittest/test_pass_split_host_device.py
@@ -0,0 +1,17 @@
+from nose.tools import raises
+import tvm
+
+@raises(Exception)
+def test_loop_dependent_allocate():
+    N = tvm.var("N")
+    A = tvm.placeholder((2*N,), "float32", "A")
+    C = tvm.compute((N, ), lambda i: A[2*i] + A[i+1], name='C')
+    s = tvm.create_schedule(C.op)
+    AA = s.cache_read(A, "local", [C])
+    s[AA].compute_at(s[C], s[C].op.axis[0])
+    # this line should fail due to IRUseDefAnalysis sees an allocate statement
+    # referencing undefined variable
+    tvm.lower(s, [A,C])
+
+if __name__ == "__main__":
+    test_loop_dependent_allocate()
-- 
GitLab