def _parse_array(self, tensor_proto):
        """Grab data in TensorProto and convert to numpy array."""
        try:
            from onnx.numpy_helper import to_array
        except ImportError:
            raise ImportError("Onnx and protobuf need to be installed. "
                              + "Instructions to install - https://github.com/onnx/onnx")
        if len(tuple(tensor_proto.dims)) > 0:
            np_array = to_array(tensor_proto).reshape(tuple(tensor_proto.dims))
        else:
            # If onnx's params are scalar values without dims mentioned.
            np_array = np.array([to_array(tensor_proto)])
        return nd.array(np_array)
def _parse_array ( self , tensor_proto ) : try : from onnx . numpy_helper import to_array except ImportError : raise ImportError ( "Onnx and protobuf need to be installed. " + "Instructions to install - https://github.com/onnx/onnx" ) if len ( tuple ( tensor_proto . dims ) ) > 0 : np_array = to_array ( tensor_proto ) . reshape ( tuple ( tensor_proto . dims ) ) else : np_array = np . array ( [ to_array ( tensor_proto ) ] ) return nd . array ( np_array )
Grab data in TensorProto and convert to numpy array.