Source code for mlprodict.onnxrt.ops_cpu.op_shape
# -*- encoding: utf-8 -*-
# pylint: disable=E0203,E1101,C0111
"""
Runtime operator.
:githublink:`%|py|7`
"""
import numpy
from ._op import OpRun
from ..shape_object import ShapeObject
[docs]class Shape(OpRun):
[docs] def __init__(self, onnx_node, desc=None, **options):
OpRun.__init__(self, onnx_node, desc=desc, **options)
[docs] def _run(self, data): # pylint: disable=W0221
return (numpy.array(data.shape, dtype=numpy.int64), )
[docs] def _infer_shapes(self, x): # pylint: disable=W0221
"""
Returns the same shape by default.
:githublink:`%|py|23`
"""
return (ShapeObject((len(x), ), dtype=numpy.int64), )