use crate::MlxCError;
use crate::compile::graph::{MlxCompiledGraph, MlxGraphBuilder};
use crate::{MlxArray, MlxBindingsContext};
const APPLY_COMPILED_MULTI_OUTPUT_GRAPH_OPERATION: &str = "apply a compiled multi-output MLX graph";
#[derive(Debug)]
pub struct MlxCompiledMultiOutputGraph {
compiled_graph: MlxCompiledGraph,
}
impl MlxCompiledMultiOutputGraph {
pub fn new(
graph_builder: MlxGraphBuilder,
compile_operation: &'static str,
shapeless: bool,
) -> Result<Self, MlxCError> {
Ok(Self {
compiled_graph: MlxCompiledGraph::new(graph_builder, compile_operation, shapeless)?,
})
}
}
impl MlxBindingsContext {
pub fn apply_compiled_multi_output_graph(
&self,
compiled_graph: &MlxCompiledMultiOutputGraph,
graph_inputs: &[&MlxArray],
) -> Result<Vec<MlxArray>, MlxCError> {
compiled_graph
.compiled_graph
.apply_multi(graph_inputs, APPLY_COMPILED_MULTI_OUTPUT_GRAPH_OPERATION)
}
}