Coverage for mlprodict/onnxrt/ops_cpu/op_mean.py: 79%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- encoding: utf-8 -*-
2# pylint: disable=E0203,E1101,C0111
3"""
4@file
5@brief Runtime operator.
6"""
7from ._op import OpRun
10class Mean(OpRun):
12 def __init__(self, onnx_node, desc=None, **options):
13 OpRun.__init__(self, onnx_node, desc=desc,
14 **options)
16 def _run(self, *args): # pylint: disable=W0221
17 if self.inplaces.get(0, False):
18 return self._run_inplace(*args)
19 res = args[0].copy()
20 for m in args[1:]:
21 res += m
22 return (res / len(args), )
24 def _run_inplace(self, *args):
25 res = args[0]
26 for m in args[1:]:
27 res += m
28 return (res / len(args), )
30 def _infer_shapes(self, *args): # pylint: disable=W0221
31 return (args[0], )
33 def _infer_types(self, *args): # pylint: disable=W0221
34 return (args[0], )
36 def _infer_sizes(self, *args, **kwargs):
37 res = self.run(*args, **kwargs)
38 return (dict(temp=0), ) + res