@@ -359,15 +359,11 @@ class GraphBuilder {
359359 vkFn (*compute_graph_, args);
360360 }
361361
362- // Parse the outputs, which will be mostly tensors. For some reason,
363- // mutable buffers are shown to be returned in the fx.Graph but do not get
364- // returned by the delegate; this may be an implementation detail of how the
365- // executorch emitter handles mutable buffers.
362+ // Parse the outputs, which will be mostly tensors but may contain tensorref
363+ // values as well if the source graph returns parameter nodes.
366364 for (const uint32_t fb_id : *flatbuffer_->output_ids ()) {
367365 const ValueRef ref = get_fb_id_valueref (fb_id);
368- if (compute_graph_->val_is_tensor (ref)) {
369- compute_graph_->set_output_tensor (ref);
370- }
366+ compute_graph_->set_output_value (ref);
371367 }
372368
373369 if (compute_graph_->graphconfig ().enable_querypool ) {
@@ -609,6 +605,12 @@ class VulkanBackend final : public ::executorch::runtime::BackendInterface {
609605 compute_graph->outputs ()[i].staging ,
610606 args[o]->toTensor ().mutable_data_ptr (),
611607 args[o]->toTensor ().numel ());
608+ }
609+ // TensorRef values represent constant tensors which will not have been
610+ // modified by the graph execution. Therefore, if a constant tensor is
611+ // returned as an output, no action is required.
612+ else if (compute_graph->val_is_tref (oref)) {
613+ continue ;
612614 } else {
613615 VK_THROW (
614616 " Could not handle output with type " ,
0 commit comments