-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbackend_interface.py
More file actions
55 lines (42 loc) · 1.38 KB
/
backend_interface.py
File metadata and controls
55 lines (42 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from abc import ABC, abstractmethod
class BackendInterface(ABC):
@abstractmethod
def add_default_layer_quantization_pruning_to_config(self, model, config):
pass
@abstractmethod
def iterative_train(self, model, config, train_func, valid_func, **kwargs):
pass
@abstractmethod
def remove_pruning_from_model(self, model, config):
pass
@abstractmethod
def add_compression_layers(self, model, config, input_shape=None):
pass
@abstractmethod
def post_epoch_functions(self, model, epoch, total_epochs, **kwargs):
pass
@abstractmethod
def post_pretrain_functions(self, model, config):
pass
@abstractmethod
def pre_epoch_functions(self, model, epoch, total_epochs):
pass
@abstractmethod
def pre_finetune_functions(self, model):
pass
@abstractmethod
def save_weights_functions(self, model):
pass
@abstractmethod
def get_layer_keep_ratio(self, model):
pass
@abstractmethod
def get_model_losses(self, model, losses):
pass
def call_post_round_functions(self, model, rewind, rounds, r):
if rewind == "round":
self.rewind_weights_functions(model)
elif rewind == "post-ticket-search" and r == rounds - 1:
self.rewind_weights_functions(model)
else:
self.post_round_functions(model)