Skip to content

Commit 94ae800

Browse files
authored
Merge branch 'main' into svekars-patch-37
2 parents 39387bd + 6053b2a commit 94ae800

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

advanced_source/cpp_extension.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,3 +1207,5 @@ examples displayed in this note `here
12071207
<https://github.com/pytorch/extension-cpp>`_. If you have questions, please use
12081208
`the forums <https://discuss.pytorch.org>`_. Also be sure to check our `FAQ
12091209
<https://pytorch.org/cppdocs/notes/faq.html>`_ in case you run into any issues.
1210+
A blog on writing extensions for AMD ROCm can be found `here
1211+
<https://rocm.blogs.amd.com/artificial-intelligence/cpp-extn/readme.html>`_.

advanced_source/python_custom_ops.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ def crop(pic: torch.Tensor, box: Sequence[int]) -> torch.Tensor:
112112
def _(pic, box):
113113
channels = pic.shape[0]
114114
x0, y0, x1, y1 = box
115-
return pic.new_empty(channels, y1 - y0, x1 - x0)
115+
result = pic.new_empty(y1 - y0, x1 - x0, channels).permute(2, 0, 1)
116+
# The result should have the same metadata (shape/strides/``dtype``/device)
117+
# as running the ``crop`` function above.
118+
return result
116119

117120
######################################################################
118121
# After this, ``crop`` now works without graph breaks:

0 commit comments

Comments
 (0)