You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "neildhickey (via GitHub)" <gi...@apache.org> on 2023/02/21 13:18:10 UTC
[GitHub] [tvm] neildhickey commented on a diff in pull request #13918: [Arith] ConstIntBound was incorrectly assuming bounds were over int64…
neildhickey commented on code in PR #13918:
URL: https://github.com/apache/tvm/pull/13918#discussion_r1113048137
##########
tests/python/relay/test_op_floordiv.py:
##########
@@ -0,0 +1,112 @@
+import numpy as np
+import pytest
+import tvm
+from tvm import te
+import scipy
+from tvm import relay
+import pytest
+from tvm.relay.testing import run_infer_type
+import tvm.topi.testing
+from tvm.contrib.nvcc import have_fp16
+import tvm.testing
+from tvm.topi.utils import get_const_tuple
+from tvm.script import tir
+
+executor_kind = tvm.testing.parameter("graph", "vm")
+
+
+@tvm.testing.uses_gpu
+def test_floor_div_op(target, dev):
+ N = 100
+ divisor = 5
+
+ @tir.prim_func
+ def func_64(
+ A: tir.Buffer[(N + 100, 2), "int64"],
+ B: tir.Buffer[(N), "int64"],
+ C: tir.Buffer[(N), "int64"],
+ ):
+ for i in tir.serial(N):
+ with tir.block("A"):
+ v_i = tir.axis.spatial(N, i)
+ A[v_i, 0] = tir.floordiv(C[v_i] - tir.max_value("int64"), divisor)
+ A[v_i, 1] = tir.floormod(C[v_i] - tir.max_value("int64"), divisor)
+ A[v_i + 100, 0] = tir.floordiv(B[v_i], divisor)
+ A[v_i + 100, 1] = tir.floormod(B[v_i], divisor)
+
+ @tir.prim_func
+ def func_32(
+ A: tir.Buffer[(N + 100, 2), "int32"],
+ B: tir.Buffer[(N), "int32"],
+ C: tir.Buffer[(N), "int32"],
+ ):
+ for i in tir.serial(N):
+ with tir.block("A"):
+ v_i = tir.axis.spatial(N, i)
+ A[v_i, 0] = tir.floordiv(C[v_i] - tir.max_value("int32"), divisor)
+ A[v_i, 1] = tir.floormod(C[v_i] - tir.max_value("int32"), divisor)
+ A[v_i + 100, 0] = tir.floordiv(B[v_i], divisor)
+ A[v_i + 100, 1] = tir.floormod(B[v_i], divisor)
+
+ @tir.prim_func
+ def func_16(
+ A: tir.Buffer[(N + 100, 2), "int16"],
+ B: tir.Buffer[(N), "int16"],
+ C: tir.Buffer[(N), "int16"],
+ ):
+ for i in tir.serial(N):
+ with tir.block("A"):
+ v_i = tir.axis.spatial(N, i)
+ A[v_i, 0] = tir.floordiv(C[v_i] - tir.max_value("int16"), divisor)
+ A[v_i, 1] = tir.floormod(C[v_i] - tir.max_value("int16"), divisor)
+ A[v_i + 100, 0] = tir.floordiv(B[v_i], divisor)
+ A[v_i + 100, 1] = tir.floormod(B[v_i], divisor)
Review Comment:
The was primarily to check the behavior of the floormod and floordiv over a random sampling of values across the whole range of integer. I think in the specific case of this test it won't be able to determine the bounds to anything other than min_value(type) max_value(type) so I suppose all it verifies is that the check isn't broken for smaller integer sizes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org