feat: chainer profiling#1552
Conversation
| from deeppavlov.core.common.errors import ConfigError | ||
| from deeppavlov.core.common.registry import register | ||
| from deeppavlov.core.data.data_learning_iterator import DataLearningIterator | ||
| from deeppavlov.core.models import component |
| if self._chainer.hist_name is not None: | ||
| self._chainer.print_hist() | ||
|
|
There was a problem hiding this comment.
I added this lines in case the user wants to see the statistics, otherwise how can we use this addition?
| serialized: Optional[bytes] = None, buckets: Optional[list] = None) -> Chainer: | ||
| """Build and return the model described in corresponding configuration file.""" | ||
| config = parse_config(config) | ||
|
|
| if self._chainer.hist_name is not None: | ||
| self._chainer.print_hist() |
| res[data_type] = report | ||
| if print_reports: | ||
| print(json.dumps({data_type: report}, ensure_ascii=False, cls=NumpyArrayEncoder)) | ||
|
|
| res = component.__call__(*x) | ||
| duration = time.perf_counter() - start_time | ||
| if hist is not None: | ||
| hist.labels(component = component).observe(duration) |
There was a problem hiding this comment.
replace whitespaces around = and use component.__class__.__name__ instead of component as value
|
|
||
| @staticmethod | ||
| def _compute(*args, param_names, pipe, targets): | ||
| def _compute(*args, param_names, pipe, targets, hist: Optional[Histogram] = None): |
There was a problem hiding this comment.
remove @staticmethod from _compute. After that there will be no need to pass hist as argument, it can be used as self.hist
|
|
||
| def __call__(self, *args): | ||
| return self._compute(*args, param_names=self.in_x, pipe=self.pipe, targets=self.out_params) | ||
| return self._compute(*args, param_names=self.in_x, pipe=self.pipe, targets=self.out_params, hist = self.hist) |
There was a problem hiding this comment.
revert after removing @staticmethod from _compute
| in_params += self.in_y | ||
|
|
||
| return self._compute(*args, pipe=pipe, param_names=in_params, targets=targets) | ||
| return self._compute(*args, pipe=pipe, param_names=in_params, targets=targets, hist = self.hist) |
There was a problem hiding this comment.
revert after removing @staticmethod from _compute
|
|
||
| model = Chainer(model_config['in'], model_config['out'], model_config.get('in_y')) | ||
|
|
||
| model = Chainer(model_config['in'], model_config['out'], model_config.get('in_y'), model_config.get('buckets')) |
There was a problem hiding this comment.
get buckets and histogram name from model_config['metadata']['profiling']
If there is no such field, don't initialize histogram, if there is such dict with parameters, initialize histogram here.
Initialized histogram should be passed to Chainer instead of buckets.
There was a problem hiding this comment.
so statistics will be valid in inference mode only
There was a problem hiding this comment.
initialize hist in case "profiling" exist without "buckets" ?
No description provided.