Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

906 B
Raw Blame
use core::marker::PhantomData;

use super::super::{channel_set::IntervalChannel, typelist::ChannelMetric};
use crate::{
    sys::ioreport::{
        IoReportGroups,
        decode::{Channel, RawChannel},
        kinds::FlowKind,
    },
    units::Bytes,
};

pub struct DramBytes<F>(PhantomData<F>);

impl<F: FlowKind> ChannelMetric for DramBytes<F> {
    type Value = Bytes;
    const TYPE_BIT: u128 = F::TYPE_BIT_BYTES;
}

impl<F: FlowKind> IntervalChannel for DramBytes<F> {
    const CHANNEL: Channel = Channel::DramBytes(F::FLOW);
    const GROUP: IoReportGroups = IoReportGroups::AMC_STATS.union(IoReportGroups::PMP);

    fn default_value() -> Self::Value {
        Bytes(0)
    }

    fn fold(
        value: &mut Self::Value,
        raw: &RawChannel,
    ) {
        let bytes = raw.integer_value;
        if bytes > 0 {
            *value = Bytes(value.value() + bytes as u64);
        }
    }
}