#![allow(unused_imports)]
use crate::arena::Arena;
use crate::device::metal_device;
use crate::kernels::kernels;
use crate::thunk::{Thunk, ThunkSchedule};
use rlx_ir::{Graph, NodeId, Op};
use rlx_opt::memory;
use std::collections::HashMap;
use super::*;
impl MetalExecutable {
pub fn output_bytes_per_node(&self) -> Vec<Vec<u8>> {
let base = self.arena.buffer.contents() as *const u8;
self.graph
.outputs
.iter()
.map(|&id| {
let off = if self.arena.has_buffer(id) {
self.arena.byte_offset(id)
} else {
0
};
let n_elems = self.graph.node(id).shape.num_elements().unwrap_or(0);
let dt = self.graph.node(id).shape.dtype();
let n_bytes = n_elems * dt.size_bytes();
unsafe { std::slice::from_raw_parts(base.add(off), n_bytes).to_vec() }
})
.collect()
}
pub fn output_dtypes(&self) -> Vec<rlx_ir::DType> {
self.graph
.outputs
.iter()
.map(|&id| self.graph.node(id).shape.dtype())
.collect()
}
pub fn output_slots(&self) -> &[(usize, usize)] {
&self.output_slots
}
}