[docs]classTorchOpOverload:""" The class is unused only to bypass a documentation warning. The alias ``TorchOpOverload`` refers to ``torch._ops.Overload``. """pass# noqa: PIE790
[docs]defmake_undefined_dimension(i:int)->"torch.SymInt":# noqa: F821""" Uses for a custom op when a new dimension must be introduced to bypass some verficiation. The following function creates a dummy output with a dimension based on the content. .. code-block:: python def symbolic_shape(x, y): return torch.empty( x.shape[0], make_undefined_dimension(min(x.shape[1], y[0])), ) """importtorcht=torch.ones((i*2,))t[:i]=0res=torch.nonzero(t).shape[0]returnres