Execution and Inference
Running SameDiff graphs — exec(), output(), batchOutput(), placeholders, and InferenceSession
How Execution Works
Setting Placeholder Values
import org.nd4j.linalg.factory.Nd4j;
import java.util.HashMap;
import java.util.Map;
INDArray inputBatch = Nd4j.create(/* your data */);
Map<String, INDArray> placeholders = new HashMap<>();
placeholders.put("input", inputBatch);sd.output() — Standard Inference
outputSingle() — Convenience for One Output
Evaluating Persistent Variables
exec() — Low-Level Graph Execution
Batch Inference
Querying Output Variable Names
Placeholder Shape Inference
Performance Considerations
Avoid recreating the SameDiff graph per request
Thread safety
Minimise requested outputs
Reuse INDArray input buffers
Working with InferenceSession Directly
Checking Graph Validity Before Execution
Last updated
Was this helpful?