Skip to content

KevinWu2017/pytorch-layer-time-profiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tools

Self-built tools for research.

PyTorch Related

1. Split_layer

This is a simple package to print each layer forward and backward time of PyTorch models.

Usage

You can use this tool by three steps:

  1. Install split_layer by running pip3 install split_layer -U --user

  2. Find the file which defines the structure of a Network. Add the following code:

from split_layer import split_layer_dec
@split_layer_dec(__file__)
class Net():

Notice: Make sure the forward function input parameter and itermediate output should be x. For example:

x = F.relu(self.conv1(x))
return x
  1. Replace loss.backward() with something like net.backward(outputs). Then you can run your training code as usual.

Others

  • It is built according to the accepted answer of this question. Now, it is not flexible enough, and DO NOT support DP or DDP models. We will develop it further in the future.

  • It works both on CPU and GPU.

Requirements

Make sure inspect and torch has been installed.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages