@@ -104,19 +104,18 @@ Error WebGPUBackend::execute(
104104 // Copy inputs from EValue tensors to GPU buffers
105105 std::vector<InputData> inputs;
106106 inputs.reserve (num_inputs);
107- for (size_t i = 0 ; i < num_inputs; i++) {
108- const auto & tensor = args[i]->toTensor ();
109- const bool host_is_int64 =
110- tensor.scalar_type () == executorch::aten::ScalarType::Long;
111- inputs.push_back ({tensor.const_data_ptr (), tensor.nbytes (), host_is_int64});
112- }
113107 // Fail loud as a runtime Error so a throw never crosses the backend boundary.
114108 try {
115- // Dynamic shapes: shrink each input to its live sizes before upload
116- // (mirrors Vulkan maybe_resize_input). No-op when unchanged, so a static
117- // graph is byte-identical.
109+ // Build the input list and, for dynamic shapes, shrink each input to its
110+ // live sizes before upload (mirrors Vulkan maybe_resize_input). No-op when
111+ // unchanged, so a static graph is byte-identical.
118112 for (size_t i = 0 ; i < num_inputs; i++) {
119- const auto sizes = args[i]->toTensor ().sizes ();
113+ const auto & tensor = args[i]->toTensor ();
114+ const bool host_is_int64 =
115+ tensor.scalar_type () == executorch::aten::ScalarType::Long;
116+ inputs.push_back (
117+ {tensor.const_data_ptr (), tensor.nbytes (), host_is_int64});
118+ const auto sizes = tensor.sizes ();
120119 std::vector<int64_t > new_dims (sizes.begin (), sizes.end ());
121120 graph->resize_input (graph->input_ids ()[i], new_dims);
122121 }
0 commit comments