Skip to content

Commit 8f3f1e2

Browse files
authored
[docs] Remove call to t() in external param example. (#18706)
Fixes #18564. The example in https://iree.dev/guides/ml-frameworks/pytorch/#using-external-parameters has an erroneous call to `t()` that actually transposes the underlying tensor instead of accessing it unmodified. This patch fixes this error, and the example now outputs a numerical match with the torch output.
1 parent e8ab5f8 commit 8f3f1e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/website/docs/guides/ml-frameworks/pytorch.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ linear_module = LinearModule(4,3)
355355
# Create a params dictionary. Note that the keys here match LinearModule's
356356
# attributes. We will use the saved safetensor file for use from the command
357357
# line.
358-
wt = linear_module.weight.t().contiguous()
359-
bias = linear_module.bias.t().contiguous()
358+
wt = linear_module.weight.data.contiguous()
359+
bias = linear_module.bias.data.contiguous()
360360
params = { "weight": wt, "bias": bias }
361361
save_file(params, "params.safetensors")
362362

0 commit comments

Comments
 (0)