Coverage for mlprodict/onnxrt/ops_cpu/op_expand.py: 87%
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 OpRun
9from ..shape_object import ShapeObject
12def common_reference_implementation(data, shape):
13 ones = numpy.ones(shape, dtype=data.dtype)
14 return data * ones
17class CommonExpand(OpRun):
19 def __init__(self, onnx_node, desc=None, expected_attributes=None, **options):
20 OpRun.__init__(
21 self, onnx_node, desc=desc,
22 expected_attributes=expected_attributes, **options)
24 def _run(self, data, shape): # pylint: disable=W0221
25 return (common_reference_implementation(data, shape), )
27 def _infer_shapes(self, data, shape): # pylint: disable=W0221
28 return (ShapeObject(None, dtype=data.dtype), )
30 def _infer_types(self, data, shape): # pylint: disable=W0221
31 return (data, )
33 def _infer_sizes(self, *args, **kwargs):
34 res = self.run(*args, **kwargs)
35 return (dict(temp=0), ) + res
38class Expand_13(CommonExpand):
40 def __init__(self, onnx_node, desc=None, **options):
41 CommonExpand.__init__(
42 self, onnx_node, desc=desc, **options)
45Expand = Expand_13