-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examples: turn examples folder into brevitas_examples package
- Loading branch information
Showing
76 changed files
with
616 additions
and
229 deletions.
There are no files selected for viewing
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
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
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
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
Empty file.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .models import * |
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
48 changes: 48 additions & 0 deletions
48
brevitas_examples/imagenet_classification/models/__init__.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
from configparser import ConfigParser | ||
|
||
from torch import hub | ||
|
||
from .mobilenetv1 import * | ||
from .vgg import * | ||
from .proxylessnas import * | ||
|
||
model_impl = { | ||
'quant_mobilenet_v1': quant_mobilenet_v1, | ||
'quant_proxylessnas_mobile14': quant_proxylessnas_mobile14 | ||
} | ||
|
||
|
||
def model_with_cfg(name, pretrained): | ||
cfg = ConfigParser() | ||
current_dir = os.path.dirname(os.path.abspath(__file__)) | ||
config_path = os.path.join(current_dir, '..', 'cfg', name + '.ini') | ||
assert os.path.exists(config_path) | ||
cfg.read(config_path) | ||
arch = cfg.get('MODEL', 'ARCH') | ||
model = model_impl[arch](cfg) | ||
if pretrained: | ||
checkpoint = cfg.get('MODEL', 'PRETRAINED_URL') | ||
state_dict = hub.load_state_dict_from_url(checkpoint, progress=True, map_location='cpu') | ||
model.load_state_dict(state_dict, strict=True) | ||
return model, cfg | ||
|
||
|
||
def quant_mobilenet_v1_4b(pretrained=True): | ||
model, _ = model_with_cfg('quant_mobilenet_v1_4b', pretrained) | ||
return model | ||
|
||
|
||
def quant_proxylessnas_mobile14_4b(pretrained=True): | ||
model, _ = model_with_cfg('quant_proxylessnas_mobile14_4b', pretrained) | ||
return model | ||
|
||
|
||
def quant_proxylessnas_mobile14_4b5b(pretrained=True): | ||
model, _ = model_with_cfg('quant_proxylessnas_mobile14_4b5b', pretrained) | ||
return model | ||
|
||
|
||
def quant_proxylessnas_mobile14_hadamard_4b(pretrained=True): | ||
model, _ = model_with_cfg('quant_proxylessnas_mobile14_hadamard_4b', pretrained) | ||
return model |
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
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
File renamed without changes.
File renamed without changes.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .quartznet import * |
Empty file.
2 changes: 1 addition & 1 deletion
2
.../quant_quartznet_perchannelscaling_4b.ini → .../quant_quartznet_perchannelscaling_4b.ini
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
2 changes: 1 addition & 1 deletion
2
.../quant_quartznet_perchannelscaling_8b.ini → .../quant_quartznet_perchannelscaling_8b.ini
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
2 changes: 1 addition & 1 deletion
2
...g/quant_quartznet_pertensorscaling_8b.ini → ...g/quant_quartznet_pertensorscaling_8b.ini
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
Empty file.
File renamed without changes.
Oops, something went wrong.