fn convert_output(
    step: &mut SessionRunArgs,
    output_type: &DataType,
    output: FetchToken,
) -> Result<Tensor> {
    macro_rules! convert {
        ($dt:ident) => {
            match step.fetch(output) {
                Err(r) => {
                    if r.code() == tensorflow::Code::InvalidArgument {
                        unsafe { Tensor::null::<$dt>(&[]).unwrap().into() }
                    } else {
                        Err(r)?
                    }
                }
                Ok(output) => tensor_to_array::<$dt>(&output)?.into(),
            }
        };
    };

    let tract_tensor = match output_type {
        DataType::Bool => convert!(bool),
        DataType::Float => convert!(f32),
        DataType::UInt8 => convert!(u8),
        DataType::Int8 => convert!(i8),
        DataType::Int32 => convert!(i32),
        DataType::Int64 => convert!(i64),
        t => bail!("Missing conversion for tensorflow type {:?}", t),
    };

    Ok(tract_tensor)
}
/// Converts the output of a Tensorflow node into a Tensor.
Converts the output of a Tensorflow node into a Tensor.
Converts the output of a Tensorflow node into a Tensor .
fn convert_output(
    step: &mut SessionRunArgs,
    output_type: &DataType,
    output: FetchToken,
) -> Result<Tensor> {
    macro_rules! convert {
        ($dt:ident) => {
            match step.fetch(output) {
                Err(r) => {
                    if r.code() == tensorflow::Code::InvalidArgument {
                        unsafe { Tensor::null::<$dt>(&[]).unwrap().into() }
                    } else {
                        Err(r)?
                    }
                }
                Ok(output) => tensor_to_array::<$dt>(&output)?.into(),
            }
        };
    };
    let tract_tensor = match output_type {
        DataType::Bool => convert!(bool),
        DataType::Float => convert!(f32),
        DataType::UInt8 => convert!(u8),
        DataType::Int8 => convert!(i8),
        DataType::Int32 => convert!(i32),
        DataType::Int64 => convert!(i64),
        t => bail!("Missing conversion for tensorflow type {:?}", t),
    };
    Ok(tract_tensor)
}
fn convert_output ( step : & mut SessionRunArgs , output_type : & DataType , output : FetchToken , ) -> Result < Tensor > { macro_rules! convert { ( $dt : ident ) => { match step fetch ( output ) { Err ( r ) { if r code ( ) tensorflow Code InvalidArgument { unsafe { Tensor null $dt ( [ ] ) unwrap ( ) into ( ) } } else { Err ( r ) } } Ok ( output ) tensor_to_array $dt ( output ) into ( ) } } ; } ; let tract_tensor = match output_type { DataType :: Bool => convert ! ( bool ) , DataType :: Float => convert ! ( f32 ) , DataType :: UInt8 => convert ! ( u8 ) , DataType :: Int8 => convert ! ( i8 ) , DataType :: Int32 => convert ! ( i32 ) , DataType :: Int64 => convert ! ( i64 ) , t => bail ! ( " " t ) , } ; Ok ( tract_tensor ) }
Converts the output of a Tensorflow node into a Tensor.
Converts the output of a Tensorflow node into a Tensor .
step
&mut SessionRunArgs
output_type
&DataType
output
FetchToken
step
&mut SessionRunArgs
output_type
&DataType
output
FetchToken