end
-function profiler.print(model, nbSamples)
- print('----------------------------------------------------------------------')
- print(model)
+function profiler.print(model, nbSamples, indent)
+ local indent = indent or ''
+
if nbSamples then
- print(string.format('acc_time %.02fs (%.01fmus/sample)',
+ print(string.format('%s%s %.02fs (%.01fmus/sample)',
+ indent,
+ model.__typename,
model.accTime,
1e6 * model.accTime / nbSamples))
else
- print(string.format('acc_time %.02fs', model.accTime))
+ print(string.format('%s%s %.02fs',
+ indent,
+ model.__typename,
+ model.accTime))
end
if torch.isTypeOf(model, nn.Container) then
for _, m in ipairs(model.modules) do
- profiler.print(m, nbSamples)
+ profiler.print(m, nbSamples, indent .. ' ')
end
end
end
-- Decor it for profiling
profiler.decor(model)
+print()
-- Create the data and criterion
profiler.print(model, nbSamples)
-print('----------------------------------------------------------------------')
+print()
print(string.format('Total model time %.02fs', modelTime))
print(string.format('Total data time %.02fs', dataTime))