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

Method main

tests/python/relax/test_analysis_estimate_memory_usage.py:72–115  ·  view source on GitHub ↗
(x: R.Tensor((2, 4), dtype="float32"))

Source from the content-addressed store, hash-verified

70
71 @R.function(pure=False)
72 def main(x: R.Tensor((2, 4), dtype="float32")) -> R.Tensor((10,), dtype="float32"):
73 cls = Module
74 storage: R.Object = R.memory.alloc_storage(
75 R.shape([32]), virtual_device_index=0, storage_scope="global", dtype="float32"
76 )
77 alloc: R.Tensor((2, 4), dtype="float32") = R.memory.alloc_tensor(
78 storage, offset=0, shape=R.shape([2, 4]), dtype="float32"
79 )
80 _: R.Tuple() = cls.exp(x, alloc)
81 lv: R.Tensor((2, 4), dtype="float32") = alloc
82 lv1: R.Tensor((8,), dtype="float32") = R.call_packed(
83 "vm.builtin.reshape", lv, R.shape([8]), sinfo_args=[R.Tensor((8,), dtype="float32")]
84 )
85 storage1: R.Object = R.memory.alloc_storage(
86 R.shape([40]), virtual_device_index=0, storage_scope="global", dtype="float32"
87 )
88 alloc1: R.Tensor((8,), dtype="float32") = R.memory.alloc_tensor(
89 storage1, offset=0, shape=R.shape([8]), dtype="float32"
90 )
91 _1: R.Tuple() = cls.relu(lv1, alloc1)
92 _2: R.Tuple() = R.memory.kill_tensor(alloc)
93 _3: R.Tuple() = R.memory.kill_tensor(lv1)
94 lv2: R.Tensor((8,), dtype="float32") = alloc1
95 alloc2: R.Tensor((8,), dtype="float32") = R.memory.alloc_tensor(
96 storage, offset=0, shape=R.shape([8]), dtype="float32"
97 )
98 _4: R.Tuple() = cls.add(lv2, R.const(1, "float32"), alloc2)
99 _5: R.Tuple() = R.memory.kill_tensor(alloc1)
100 lv3: R.Tensor((8,), dtype="float32") = alloc2
101 alloc3: R.Tensor((10,), dtype="float32") = R.memory.alloc_tensor(
102 storage1, offset=0, shape=R.shape([10]), dtype="float32"
103 )
104 _6: R.Tuple() = cls.pad(lv3, alloc3)
105 _7: R.Tuple() = R.memory.kill_tensor(alloc2)
106 lv4: R.Tensor((10,), dtype="float32") = alloc3
107 alloc4: R.Tensor((10,), dtype="float32") = R.builtin.alloc_tensor(
108 R.shape([10]), dtype="float32", runtime_device_index=0
109 )
110 _8: R.Tuple() = cls.log(lv4, alloc4)
111 _9: R.Tuple() = R.memory.kill_tensor(alloc3)
112 gv5: R.Tensor((10,), dtype="float32") = alloc4
113 _11: R.Tuple() = R.memory.kill_storage(storage)
114 _10: R.Tuple() = R.memory.kill_storage(storage1)
115 return gv5
116
117 assert (
118 estimate_memory_usage(Module)

Calls 8

TensorMethod · 0.80
call_packedMethod · 0.80
shapeMethod · 0.45
expMethod · 0.45
reluMethod · 0.45
addMethod · 0.45
padMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected