Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jagged slice op for cpu #1690

Closed
wants to merge 1 commit into from

Commits on Apr 19, 2023

  1. Add jagged slice op for cpu (pytorch#1690)

    Summary:
    Pull Request resolved: pytorch#1690
    
    The context why this is needed is as follows
    1) For really long sparse features we want to split them into multiple chunks that can be fed into the model
    2) Slicing requires users to require per row start point & a maximum L.
    
    Based on these requirements, a custom op mimicing the slice semantics of a normal tensor works best.
    
    An example usage using pseudo code
    
    ```
    input_jagged_tensor = [[1, 2, 3, 4], [1, 2, 3], [1, 2, 3, 4, 5, 6], [1], [1, 2]]
    start = [0, 0, 0, 0, 0]
    slice_length = 3
    
    >> jagged_slice(input_jagged_tensor, start, slice_length)
    
    output_jagged_tensor = [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1], [1, 2]]
    
    ```
    
    A corresponding operation for dense tensor would look like
    ```
    dense_tensor = torch.randn((8, 10))
    slice_dense_tensor = dense_tensor[:, 1:3]
    ```
    
    Reviewed By: sryap
    
    Differential Revision: D44299744
    
    fbshipit-source-id: 982ba26987643cbb778fdfac7d9ac4fd79d8b369
    Devashish Tyagi authored and facebook-github-bot committed Apr 19, 2023
    Configuration menu
    Copy the full SHA
    03c6990 View commit details
    Browse the repository at this point in the history