Last active
October 17, 2018 07:43
-
-
Save belltailjp/924a6f88c5ccc122a4de964b447308b0 to your computer and use it in GitHub Desktop.
chainer_computational_cost (used from a blog post in daily.belltail.jp)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chainer | |
import chainer.links as L | |
import numpy as np | |
import chainer_computational_cost as c3 | |
net = L.VGG16Layers() | |
x = np.random.random((1, 3, 224, 224)).astype(np.float32) # dummy input | |
with chainer.no_backprop_mode(), chainer.using_config('train', False): | |
with c3.ComputationalCostHook(fma_1flop=True) as cch: | |
y = net(x) | |
cch.show_summary_report(mode='table') # ← |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+-----------------------+----------+--------+---------+----------+--------+ | |
| Layer type | # Layers | GFLOPs | MemRead | MemWrite | MemR+W | | |
| | | | GiB | GiB | GiB | | |
+=======================+==========+========+=========+==========+========+ | |
| Convolution2DFunction | 13 | 15.347 | 0.089 | 0.05 | 0.139 | | |
+-----------------------+----------+--------+---------+----------+--------+ | |
| ReLU | 15 | 0.014 | 0.05 | 0.05 | 0.101 | | |
+-----------------------+----------+--------+---------+----------+--------+ | |
| MaxPooling2D | 5 | 0.005 | 0.023 | 0.006 | 0.029 | | |
+-----------------------+----------+--------+---------+----------+--------+ | |
| Reshape | 1 | 0.0 | 0.0 | 0.0 | 0.0 | | |
+-----------------------+----------+--------+---------+----------+--------+ | |
| LinearFunction | 3 | 0.124 | 0.461 | 0.0 | 0.461 | | |
+-----------------------+----------+--------+---------+----------+--------+ | |
| Softmax | 1 | 0.0 | 0.0 | 0.0 | 0.0 | | |
+-----------------------+----------+--------+---------+----------+--------+ | |
| total | 38 | 15.488 | 0.623 | 0.107 | 0.729 | | |
+-----------------------+----------+--------+---------+----------+--------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment