Ejemplo n.º 1
0
    def backward(ctx, grad_output):
        input, offset, mask, weight, bias = ctx.saved_tensors
        grad_input, grad_offset, grad_mask, grad_weight, grad_bias = _backend.dcn_v2_backward(
            input,
            weight,
            bias,
            offset,
            mask,
            grad_output,
            ctx.kernel_size[0],
            ctx.kernel_size[1],
            ctx.stride[0],
            ctx.stride[1],
            ctx.padding[0],
            ctx.padding[1],
            ctx.dilation[0],
            ctx.dilation[1],
            ctx.deformable_groups,
        )

        return (
            grad_input,
            grad_offset,
            grad_mask,
            grad_weight,
            grad_bias,
            None,
            None,
            None,
            None,
        )
Ejemplo n.º 2
0
    def backward(ctx, grad_output):
        if use_amp:
            grad_output = grad_output.float()

        input, offset, mask, weight, bias = ctx.saved_tensors
        (
            grad_input,
            grad_offset,
            grad_mask,
            grad_weight,
            grad_bias,
        ) = _backend.dcn_v2_backward(
            input,
            weight,
            bias,
            offset,
            mask,
            grad_output,
            ctx.kernel_size[0],
            ctx.kernel_size[1],
            ctx.stride[0],
            ctx.stride[1],
            ctx.padding[0],
            ctx.padding[1],
            ctx.dilation[0],
            ctx.dilation[1],
            ctx.deformable_groups,
        )

        if use_amp:
            grad_input = grad_input.half()
            grad_offset = grad_offset.half()
            grad_mask = grad_mask.half()
            grad_weight = grad_weight.half()
            grad_bias = grad_bias.half()

        return (
            grad_input,
            grad_offset,
            grad_mask,
            grad_weight,
            grad_bias,
            None,
            None,
            None,
            None,
        )