Esempio n. 1
0
    def forward(
        ctx,
        input_features,
        tensor_stride=1,
        stride=1,
        kernel_size=-1,
        dilation=1,
        region_type=-1,
        region_offset=None,
        average=False,
        in_coords_key=None,
        out_coords_key=None,
        coords_manager=None,
    ):
        assert isinstance(region_type, RegionType)
        if out_coords_key is None:
            out_coords_key = CoordsKey(in_coords_key.D)
        assert in_coords_key.D == out_coords_key.D
        tensor_stride, stride, kernel_size, dilation, region_type = prep_args(
            tensor_stride, stride, kernel_size, dilation, region_type,
            in_coords_key.D)

        if region_offset is None:
            region_offset = torch.IntTensor()

        ctx.in_feat = input_features
        out_feat = input_features.new()
        ctx.num_nonzero = input_features.new()
        ctx = save_ctx(
            ctx,
            tensor_stride,
            stride,
            kernel_size,
            dilation,
            region_type,
            in_coords_key,
            out_coords_key,
            coords_manager,
        )
        D = in_coords_key.D
        fw_fn = get_minkowski_function("PoolingTransposeForward",
                                       input_features)
        fw_fn(
            ctx.in_feat,
            out_feat,
            ctx.num_nonzero,
            convert_to_int_list(ctx.tensor_stride, D),
            convert_to_int_list(ctx.stride, D),
            convert_to_int_list(ctx.kernel_size, D),
            convert_to_int_list(ctx.dilation, D),
            region_type,
            region_offset,
            ctx.in_coords_key.CPPCoordsKey,
            ctx.out_coords_key.CPPCoordsKey,
            ctx.coords_man.CPPCoordsManager,
        )
        return out_feat
    def forward(
        ctx,
        input_features: torch.Tensor,
        pooling_mode: PoolingMode,
        kernel_generator: KernelGenerator,
        in_coordinate_map_key: CoordinateMapKey,
        out_coordinate_map_key: CoordinateMapKey = None,
        coordinate_manager: CoordinateManager = None,
    ):
        if out_coordinate_map_key is None:
            out_coordinate_map_key = CoordinateMapKey(
                in_coordinate_map_key.get_coordinate_size())

        input_features = input_features.contiguous()
        ctx.input_features = input_features
        ctx = save_ctx(
            ctx,
            kernel_generator,
            in_coordinate_map_key,
            out_coordinate_map_key,
            coordinate_manager,
        )
        ctx.pooling_mode = pooling_mode

        fw_fn = get_minkowski_function("LocalPoolingTransposeForward",
                                       input_features)
        out_feat, num_nonzero = fw_fn(
            ctx.input_features,
            kernel_generator.kernel_size,
            kernel_generator.kernel_stride,
            kernel_generator.kernel_dilation,
            kernel_generator.region_type,
            kernel_generator.region_offsets,
            kernel_generator.expand_coordinates,
            pooling_mode,
            ctx.in_coordinate_map_key,
            ctx.out_coordinate_map_key,
            ctx.coordinate_manager._manager,
        )
        ctx.num_nonzero = num_nonzero
        return out_feat
Esempio n. 3
0
    def forward(
        ctx,
        input_features: torch.Tensor,
        kernel_weights: torch.Tensor,
        kernel_generator: KernelGenerator,
        in_coordinate_map_key: CoordinateMapKey,
        out_coordinate_map_key: CoordinateMapKey = None,
        coordinate_manager: CoordinateManager = None,
    ):
        if out_coordinate_map_key is None:
            out_coordinate_map_key = CoordinateMapKey(
                in_coordinate_map_key.get_coordinate_size())
        if not input_features.is_contiguous():
            input_features = input_features.contiguous()

        ctx.input_features = input_features
        ctx.kernel_weights = kernel_weights
        ctx = save_ctx(
            ctx,
            kernel_generator,
            in_coordinate_map_key,
            out_coordinate_map_key,
            coordinate_manager,
        )

        fw_fn = get_minkowski_function("ConvolutionTransposeForward",
                                       input_features)
        return fw_fn(
            ctx.input_features,
            kernel_weights,
            kernel_generator.kernel_size,
            kernel_generator.kernel_stride,
            kernel_generator.kernel_dilation,
            kernel_generator.region_type,
            kernel_generator.region_offsets,
            kernel_generator.expand_coordinates,
            ctx.in_coordinate_map_key,
            ctx.out_coordinate_map_key,
            ctx.coordinate_manager._manager,
        )