fn agreed_type(
    input_shapes: &[&Shape],
    output_shapes: &[&Shape],
) -> Result<ScalarType, CompileError> {
    let mut data_type: Option<ScalarType> = None;

    for input_shape in input_shapes {
        let input_type = input_shape.data_type;
        match data_type {
            Some(dt) => {
                if dt != input_type {
                    return Err(CompileError::TypesDisagree(dt, input_type));
                }
            }
            None => data_type = Some(input_type),
        }
    }

    for output_shape in output_shapes {
        let output_type = output_shape.data_type;
        match data_type {
            Some(dt) => {
                if dt != output_type {
                    return Err(CompileError::TypesDisagree(dt, output_type));
                }
            }
            None => data_type = Some(output_type),
        }
    }

    if let Some(ScalarType::I64) = data_type {
        data_type = Some(ScalarType::I32);
    }

    data_type.ok_or(CompileError::TypeUnderspecified)
}
/// Returns the data type of the input and output shapes, but error if these types differ or when no input/output was specified
Returns the data type of the input and output shapes, but error if these types differ or when no input/output was specified
Returns the data type of the input and output shapes but error if these types differ or when no input / output was specified
fn agreed_type(
    input_shapes: &[&Shape],
    output_shapes: &[&Shape],
) -> Result<ScalarType, CompileError> {
    let mut data_type: Option<ScalarType> = None;
    for input_shape in input_shapes {
        let input_type = input_shape.data_type;
        match data_type {
            Some(dt) => {
                if dt != input_type {
                    return Err(CompileError::TypesDisagree(dt, input_type));
                }
            }
            None => data_type = Some(input_type),
        }
    }
    for output_shape in output_shapes {
        let output_type = output_shape.data_type;
        match data_type {
            Some(dt) => {
                if dt != output_type {
                    return Err(CompileError::TypesDisagree(dt, output_type));
                }
            }
            None => data_type = Some(output_type),
        }
    }
    if let Some(ScalarType::I64) = data_type {
        data_type = Some(ScalarType::I32);
    }
    data_type.ok_or(CompileError::TypeUnderspecified)
}
fn agreed_type ( input_shapes : & [ & Shape ] , output_shapes : & [ & Shape ] , ) -> Result < ScalarType , CompileError > { let mut data_type : Option < ScalarType > = None ; for input_shape in input_shapes { let input_type = input_shape . data_type ; match data_type { Some ( dt ) => { if dt != input_type { return Err ( CompileError :: TypesDisagree ( dt , input_type ) ) ; } } None => data_type = Some ( input_type ) , } } for output_shape in output_shapes { let output_type = output_shape . data_type ; match data_type { Some ( dt ) => { if dt != output_type { return Err ( CompileError :: TypesDisagree ( dt , output_type ) ) ; } } None => data_type = Some ( output_type ) , } } if let Some ( ScalarType :: I64 ) = data_type { data_type = Some ( ScalarType :: I32 ) ; } data_type . ok_or ( CompileError :: TypeUnderspecified ) }
Returns the data type of the input and output shapes, but error if these types differ or when no input/output was specified
Returns the data type of the input and output shapes but error if these types differ or when no input / output was specified
input_shapes
&[&Shape]
output_shapes
&[&Shape]
input_shapes
&[&Shape]
output_shapes
&[&Shape]