Skip to content

Commit

Permalink
Remove compilation and run in the nn module test
Browse files Browse the repository at this point in the history
  • Loading branch information
yongwww committed Feb 15, 2024
1 parent f904508 commit abbe733
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions tests/python/relax/test_frontend_nn_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,9 +840,7 @@ def test(self):
vm["test"](*effects)


@tvm.testing.requires_gpu
def test_multinomial_from_uniform():
import numpy as np

prob_shape = (4, 5)
sample_shape = (4, 1)
Expand Down Expand Up @@ -904,25 +902,6 @@ def foo(prob: R.Tensor((4, 5), dtype="float32"), uniform_sample: R.Tensor((4, 1)

tvm.ir.assert_structural_equal(mod, Expected)

target = tvm.target.Target("cuda", host="llvm")
with target:
mod = tir.transform.DefaultGPUSchedule()(mod)
ex = relax.build(mod, target)
dev = tvm.cuda(0)
vm = relax.VirtualMachine(ex, dev)

effects = vm["_initialize_effect"]()

np_rand = np.random.rand(*prob_shape).astype(np.float32)
# normalize it to get the random prob
np_prob = np_rand / np_rand.sum(axis=1, keepdims=True)
nd_prob = tvm.nd.array(np_prob, dev)
# special sample to get deterministic results
nd_sample = tvm.nd.array(np.array([[1], [0], [0], [1.1]]).astype(np.float32), dev)
inputs = [nd_prob, nd_sample, effects]
res = vm["foo"](*inputs)
tvm.testing.assert_allclose(res[0].numpy(), np.array([[4], [0], [0], [4]]).astype(np.int64))


if __name__ == "__main__":
tvm.testing.main()

0 comments on commit abbe733

Please sign in to comment.