[docs]deffrom_array_extended(tensor:np.ndarray,name:Optional[str]=None)->TensorProto:""" Converts an array into a TensorProto. :param tensor: numpy array :param name: name :return: TensorProto """dt=tensor.dtypeifdt==float8e4m3fnanddt.descr[0][0]=="e4m3fn":to=TensorProto.FLOAT8E4M3FNdt_to=np.uint8elifdt==float8e4m3fnuzanddt.descr[0][0]=="e4m3fnuz":to=TensorProto.FLOAT8E4M3FNUZdt_to=np.uint8elifdt==float8e5m2anddt.descr[0][0]=="e5m2":to=TensorProto.FLOAT8E5M2dt_to=np.uint8elifdt==float8e5m2fnuzanddt.descr[0][0]=="e5m2fnuz":to=TensorProto.FLOAT8E5M2FNUZdt_to=np.uint8elifdt==bfloat16anddt.descr[0][0]=="bfloat16":to=TensorProto.BFLOAT16dt_to=np.uint16else:returnonnx_from_array(tensor,name)t=onnx_from_array(tensor.astype(dt_to),name)t.data_type=toreturnt