Coverage for mlprodict/onnxrt/ops_cpu/op_feature_vectorizer.py: 85%

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

20 statements  

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 

11class FeatureVectorizer(OpRun): 

12 """ 

13 Very similar to @see cl Concat. 

14 """ 

15 

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

17 OpRun.__init__(self, onnx_node, desc=desc, 

18 **options) 

19 self.axis = 1 

20 

21 def _preprocess(self, a): 

22 if self.axis >= len(a.shape): 

23 new_shape = a.shape + (1, ) * (self.axis + 1 - len(a.shape)) 

24 return a.reshape(new_shape) 

25 return a 

26 

27 def _run(self, *args): # pylint: disable=W0221 

28 args = [self._preprocess(a) for a in args] 

29 res = numpy.concatenate(args, self.axis) 

30 return (res, ) 

31 

32 def _infer_shapes(self, *args): # pylint: disable=W0221 

33 return (args[0].concat_columns(self.axis, *(args[1:])), ) 

34 

35 def _infer_types(self, *args): # pylint: disable=W0221 

36 return (args[0], )