Coverage for mlprodict/onnxrt/ops_cpu/op_inverse.py: 94%
17 statements
« prev ^ index » next coverage.py v7.1.0, created at 2023-02-04 02:28 +0100
« prev ^ index » next coverage.py v7.1.0, created at 2023-02-04 02:28 +0100
1# -*- encoding: utf-8 -*-
2# pylint: disable=E0203,E1101,C0111
3"""
4@file
5@brief Runtime operator.
6"""
7import numpy
8from ._op import OpRunUnaryNum
9from ._new_ops import OperatorSchema
12class Inverse(OpRunUnaryNum):
14 def __init__(self, onnx_node, desc=None, **options):
15 OpRunUnaryNum.__init__(self, onnx_node, desc=desc,
16 **options)
18 def _run(self, x, attributes=None, verbose=0, fLOG=None): # pylint: disable=W0221
19 return (numpy.linalg.inv(x), )
21 def to_python(self, inputs):
22 return ("import numpy.linalg", f"return numpy.linalg({inputs[0]})")
24 def _find_custom_operator_schema(self, op_name):
25 """
26 Finds a custom operator defined by this runtime.
27 """
28 return InverseSchema()
31class InverseSchema(OperatorSchema):
32 """
33 Defines a schema for operators added in this package
34 such as @see cl Inverse.
35 """
37 def __init__(self):
38 OperatorSchema.__init__(self, 'Inverse')
39 self.attributes = {}