Skip to content

Commit d0ff38b

Browse files
committed
README tweak
1 parent d924bd2 commit d0ff38b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,36 @@ g = generateGraph(net, input)
6060
graph.dot(g,modelname..'_optimized',modelname..'_optimized')
6161
```
6262
![GoogleNet with memory optimization](doc/googlenet_optimized.gif)
63+
64+
## Counting the amount of saved memory
65+
66+
We can also provide a function to compute the amount of memory used by the network
67+
in bytes, which allows us to check the amount of saved memory. It currently
68+
counts only the `output` fields of each module, and not it's internal buffers.
69+
70+
Here is an example
71+
72+
```lua
73+
optnet = require 'optnet'
74+
utils = require 'optnet.utils'
75+
usedMemory = utils.usedMemory
76+
77+
models = require 'optnet.models'
78+
modelname = 'googlenet'
79+
net, input = models[modelname]()
80+
81+
mem1 = usedMemory(net, input)
82+
83+
optnet.optimizeMemory(net, input)
84+
85+
mem2 = usedMemory(net, input)
86+
87+
optnet.removeOptimization(net)
88+
89+
mem3 = usedMemory(net, input)
90+
91+
print('Before optimization : '.. mem1/1024/1024 .. ' MBytes')
92+
print('After optimization : '.. mem2/1024/1024 .. ' MBytes')
93+
print('After removing optimization: '.. mem3/1024/1024 .. ' MBytes')
94+
95+
```

0 commit comments

Comments
 (0)