[jacinto-ai/pytorch-jacinto-ai-devkit.git] / modules / pytorch_jacinto_ai / vision / models / utils.py
diff --git a/modules/pytorch_jacinto_ai/vision/models/utils.py b/modules/pytorch_jacinto_ai/vision/models/utils.py
index bf886cfdbe76e422dba27a239e9719e15b7bc48b..c2f7385660281f0c4b52c576e3604589c6dfd6e9 100644 (file)
from torch.utils.model_zoo import load_url as load_state_dict_from_url
-def make_divisible(v, divisor, min_value=None):
- """
- This function is taken from the original tf repo.
- It ensures that all layers have a channel number that is divisible by 8
- It can be seen here:
- https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py
- :param v:
- :param divisor:
- :param min_value:
- :return:
- """
- if min_value is None:
- min_value = divisor
- new_v = max(min_value, int(v + divisor / 2) // divisor * divisor)
- # Make sure that round down does not go down by more than 10%.
- if new_v < 0.9 * v:
- new_v += divisor
- return int(new_v)
-
-def make_divisible_by8(v):
- return make_divisible(v, 8)