MCPcopy Create free account
hub / github.com/apache/tvm / test_leakyrelu

Function test_leakyrelu

tests/python/relax/test_frontend_from_exported_program.py:932–971  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

930
931
932def test_leakyrelu():
933 import torch
934 from torch.nn import Module
935
936 torch.set_grad_enabled(False)
937
938 class LeakyReLU0(Module):
939 def __init__(self):
940 super().__init__()
941 self.leakyrelu = torch.nn.LeakyReLU(0.02)
942
943 def forward(self, input):
944 return self.leakyrelu(input)
945
946 class LeakyReLU1(Module):
947 def forward(self, input):
948 return torch.nn.functional.leaky_relu(input, 0.02)
949
950 class LeakyReLU2(Module):
951 def forward(self, input):
952 return torch.ops.aten.leaky_relu_(input, 0.02)
953
954 @tvm.script.ir_module
955 class expected_for_1_2:
956 @R.function
957 def main(input_1: R.Tensor((1, 3, 10, 10), dtype="float32")) -> R.Tuple(
958 R.Tensor((1, 3, 10, 10), dtype="float32")
959 ):
960 # block 0
961 with R.dataflow():
962 lv: R.Tensor((1, 3, 10, 10), dtype="float32") = R.nn.leakyrelu(input_1, alpha=0.02)
963 gv: R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")) = (lv,)
964 R.output(gv)
965 return gv
966
967 example_args = (torch.randn(1, 3, 10, 10, dtype=torch.float32),)
968 verify_model(LeakyReLU0(), example_args, {}, expected_for_1_2)
969 verify_model(LeakyReLU1(), example_args, {}, expected_for_1_2)
970 # In-place leaky_relu_ yields the same program; mutation outputs are dropped.
971 verify_model(LeakyReLU2(), example_args, {}, expected_for_1_2)
972
973
974def test_logaddexp():

Callers

nothing calls this directly

Calls 4

LeakyReLU2Class · 0.85
verify_modelFunction · 0.70
LeakyReLU0Class · 0.70
LeakyReLU1Class · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…