Coverage for mlprodict/onnxrt/ops_cpu/op_max.py: 92%
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"""
7import numpy
8from ._op import OpRunBinaryNumpy
11class Max(OpRunBinaryNumpy):
13 def __init__(self, onnx_node, desc=None, **options):
14 OpRunBinaryNumpy.__init__(self, numpy.maximum, onnx_node,
15 desc=desc, **options)
17 def run(self, *data): # pylint: disable=W0221
18 if len(data) == 2:
19 return OpRunBinaryNumpy.run(self, *data)
20 if len(data) == 1:
21 if self.inplaces.get(0, False):
22 return (data, )
23 return (data.copy(), )
24 if len(data) > 2:
25 a = data[0]
26 for i in range(1, len(data)):
27 a = numpy.maximum(a, data[i])
28 return (a, )
29 raise RuntimeError("Unexpected turn of events.")
31 def _infer_shapes(self, x, *y): # pylint: disable=W0221
32 res = x
33 for i in range(len(y)): # pylint: disable=C0200
34 res = OpRunBinaryNumpy._infer_shapes(self, res, y[i])[0]
35 return (res, )
37 def _infer_types(self, x, *y): # pylint: disable=W0221
38 """
39 Returns the boolean type.
40 """
41 return (x, )