MCPcopy
hub / github.com/pytorch/vision / test_builtin_tv_tensor_subclass

Method test_builtin_tv_tensor_subclass

test/test_transforms_v2.py:3138–3170  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3136 assert _get_kernel(resize_with_pure_kernels, input_type) is kernel
3137
3138 def test_builtin_tv_tensor_subclass(self):
3139 # We cannot use F.resize together with self.KERNELS mapping here directly here, since this is only the
3140 # ideal wrapping. Practically, we have an intermediate wrapper layer. Thus, we create a new resize functional
3141 # here, register the kernels without wrapper, and check if subclasses of our builtin tv_tensors get dispatched
3142 # to the kernel of the corresponding superclass
3143 def resize_with_pure_kernels():
3144 pass
3145
3146 class MyImage(tv_tensors.Image):
3147 pass
3148
3149 class MyBoundingBoxes(tv_tensors.BoundingBoxes):
3150 pass
3151
3152 class MyMask(tv_tensors.Mask):
3153 pass
3154
3155 class MyVideo(tv_tensors.Video):
3156 pass
3157
3158 for custom_tv_tensor_subclass in [
3159 MyImage,
3160 MyBoundingBoxes,
3161 MyMask,
3162 MyVideo,
3163 ]:
3164 builtin_tv_tensor_class = custom_tv_tensor_subclass.__mro__[1]
3165 builtin_tv_tensor_kernel = self.KERNELS[builtin_tv_tensor_class]
3166 _register_kernel_internal(resize_with_pure_kernels, builtin_tv_tensor_class, tv_tensor_wrapper=False)(
3167 builtin_tv_tensor_kernel
3168 )
3169
3170 assert _get_kernel(resize_with_pure_kernels, custom_tv_tensor_subclass) is builtin_tv_tensor_kernel
3171
3172 def test_tv_tensor_subclass(self):
3173 class MyTVTensor(tv_tensors.TVTensor):

Callers

nothing calls this directly

Calls 2

_get_kernelFunction · 0.90

Tested by

no test coverage detected