File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -584,11 +584,11 @@ do {
584584 // Execute a potentially different method by name.
585585 let outputs3 = try module.execute("another_method", inputs: [Value(inputTensor1)])
586586
587- // Process outputs (assuming first output is a tensor) .
588- if let resultTensor = outputs1.first?.tensor {
589- resultTensor.bytes { ptr, count, dtype in
590- // Access result data.
591- }
587+ // Process outputs by converting the first output Value to a typed Tensor<Float> .
588+ if let outputTensor: Tensor<Float> = outputs1.first?.tensor() {
589+ // Now you have a type-safe tensor and can access its data easily.
590+ let logits = try outputTensor.scalars()
591+ print("First 5 logits: \(logits.prefix(5))")
592592 }
593593} catch {
594594 print("Execution failed: \(error)")
You can’t perform that action at this time.
0 commit comments