Skip to content

Commit 531fd0b

Browse files
authored
Merge branch 'main' into imagenet
2 parents f4da8d5 + 2975710 commit 531fd0b

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

packaging/build_conda.sh

-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,4 @@ setup_visual_studio_constraint
1313
setup_junit_results_folder
1414
export CUDATOOLKIT_CHANNEL="nvidia"
1515

16-
if [[ "$PYTHON_VERSION" == "3.11" ]]; then
17-
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c malfet"
18-
fi
19-
2016
conda build -c $CUDATOOLKIT_CHANNEL $CONDA_CHANNEL_FLAGS --no-anaconda-upload --no-test --python "$PYTHON_VERSION" packaging/torchvision

torchvision/_meta_registrations.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import functools
2+
13
import torch
24
import torch.library
35

@@ -6,20 +8,22 @@
68

79
from torch._prims_common import check
810

9-
_meta_lib = torch.library.Library("torchvision", "IMPL", "Meta")
1011

11-
vision = torch.ops.torchvision
12+
@functools.lru_cache(None)
13+
def get_meta_lib():
14+
return torch.library.Library("torchvision", "IMPL", "Meta")
1215

1316

14-
def register_meta(op):
17+
def register_meta(op_name, overload_name="default"):
1518
def wrapper(fn):
16-
_meta_lib.impl(op, fn)
19+
if torchvision.extension._has_ops():
20+
get_meta_lib().impl(getattr(getattr(torch.ops.torchvision, op_name), overload_name), fn)
1721
return fn
1822

1923
return wrapper
2024

2125

22-
@register_meta(vision.roi_align.default)
26+
@register_meta("roi_align")
2327
def meta_roi_align(input, rois, spatial_scale, pooled_height, pooled_width, sampling_ratio, aligned):
2428
check(rois.size(1) == 5, lambda: "rois must have shape as Tensor[K, 5]")
2529
check(
@@ -34,7 +38,7 @@ def meta_roi_align(input, rois, spatial_scale, pooled_height, pooled_width, samp
3438
return input.new_empty((num_rois, channels, pooled_height, pooled_width))
3539

3640

37-
@register_meta(vision._roi_align_backward.default)
41+
@register_meta("_roi_align_backward")
3842
def meta_roi_align_backward(
3943
grad, rois, spatial_scale, pooled_height, pooled_width, batch_size, channels, height, width, sampling_ratio, aligned
4044
):

torchvision/datapoints/_dataset_wrapper.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def wrap_dataset_for_transforms_v2(dataset, target_keys=None):
3838
* :class:`~torchvision.datasets.CocoDetection`: Instead of returning the target as list of dicts, the wrapper
3939
returns a dict of lists. In addition, the key-value-pairs ``"boxes"`` (in ``XYXY`` coordinate format),
4040
``"masks"`` and ``"labels"`` are added and wrap the data in the corresponding ``torchvision.datapoints``.
41-
The original keys are preserved. If ``target_keys`` is ommitted, returns only the values for the ``"boxes"``
42-
and ``"labels"``.
41+
The original keys are preserved. If ``target_keys`` is ommitted, returns only the values for the
42+
``"image_id"``, ``"boxes"``, and ``"labels"``.
4343
* :class:`~torchvision.datasets.VOCDetection`: The key-value-pairs ``"boxes"`` and ``"labels"`` are added to
4444
the target and wrap the data in the corresponding ``torchvision.datapoints``. The original keys are
4545
preserved. If ``target_keys`` is ommitted, returns only the values for the ``"boxes"`` and ``"labels"``.
@@ -328,7 +328,7 @@ def coco_dectection_wrapper_factory(dataset, target_keys):
328328
"masks",
329329
"labels",
330330
},
331-
default={"boxes", "labels"},
331+
default={"image_id", "boxes", "labels"},
332332
)
333333

334334
def segmentation_to_mask(segmentation, *, spatial_size):

0 commit comments

Comments
 (0)