This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 75165e1fff [TEST][CLML] Clip test case updated (#17517)
75165e1fff is described below
commit 75165e1fffddc4b47ab23a3ae9ce12b2a89b54fe
Author: Siva <[email protected]>
AuthorDate: Tue Nov 12 19:07:38 2024 +0530
[TEST][CLML] Clip test case updated (#17517)
clip test case updated (#59)
Test case for clip layer added
---
tests/python/contrib/test_clml/test_ops.py | 45 ++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/tests/python/contrib/test_clml/test_ops.py
b/tests/python/contrib/test_clml/test_ops.py
index d8473b01ef..425990f793 100644
--- a/tests/python/contrib/test_clml/test_ops.py
+++ b/tests/python/contrib/test_clml/test_ops.py
@@ -1313,5 +1313,50 @@ def test_batch_flatten(remote, dtype, target,
executor_type):
_verify(*(_get_model((1, 128, 4, 4))))
[email protected]("dtype", ["float16", "float32"])
[email protected](
+ "trials",
+ [
+ [(1, 32, 256, 256), -1, 1],
+ [(1, 8, 64, 64), 0, 1],
+ ],
+)
[email protected]_openclml
[email protected]_targets("opencl -device=adreno")
+def test_clip(remote, dtype, target, executor_type, trials):
+ def _verify(shape, a_min, a_max):
+ np.random.seed(0)
+ a = relay.var("a", shape=(shape), dtype=dtype)
+ out = relay.clip(a, a_min, a_max)
+ inputs = {"a": tvm.nd.array(np.random.uniform(-1, 1,
shape).astype(dtype))}
+ params = {}
+ mod = IRModule.from_expr(out)
+ outputs = _build_and_run_network(remote, mod, params, inputs, target,
executor_type)
+ out_tol = 1e-3 if dtype == "float16" else 1e-5
+ tvm.testing.assert_allclose(
+ outputs[0].asnumpy(), outputs[1].asnumpy(), rtol=out_tol,
atol=out_tol
+ )
+ exp_codegen = [
+ {"attrs": {"dtype": [[dtype]], "shape": [[shape]]}, "name": "",
"op": "input"},
+ {
+ "attrs": {
+ "a_max": [[str(a_max)]],
+ "a_min": [[str(a_min)]],
+ "dtype": [[dtype]],
+ "num_inputs": "1",
+ "num_outputs": "1",
+ "shape": [[shape]],
+ },
+ "inputs": [[0, 0, 0]],
+ "name": "clip",
+ "op": "kernel",
+ },
+ ]
+
+ verify_codegen(remote, mod, params, exp_codegen, target)
+
+ _verify(trials[0], trials[1], trials[2])
+
+
if __name__ == "__main__":
tvm.testing.main()