Coverage for mlprodict/onnxrt/ops_cpu/op_expand.py: 100%

15 statements  

« 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 OpRun 

9 

10 

11def common_reference_implementation(data, shape): 

12 ones = numpy.ones(shape, dtype=data.dtype) 

13 return data * ones 

14 

15 

16class CommonExpand(OpRun): 

17 

18 def __init__(self, onnx_node, desc=None, expected_attributes=None, **options): 

19 OpRun.__init__( 

20 self, onnx_node, desc=desc, 

21 expected_attributes=expected_attributes, **options) 

22 

23 def _run(self, data, shape, attributes=None, verbose=0, fLOG=None): # pylint: disable=W0221 

24 return (common_reference_implementation(data, shape), ) 

25 

26 

27class Expand_13(CommonExpand): 

28 

29 def __init__(self, onnx_node, desc=None, **options): 

30 CommonExpand.__init__( 

31 self, onnx_node, desc=desc, **options) 

32 

33 

34Expand = Expand_13