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

Scatter Optimizations with Window Dims specified #308

Open
giordano opened this issue Feb 2, 2025 · 3 comments
Open

Scatter Optimizations with Window Dims specified #308

giordano opened this issue Feb 2, 2025 · 3 comments

Comments

@giordano
Copy link
Member

giordano commented Feb 2, 2025

julia> using Reactant
AssertionError("Could not find registered platform with name: \"cuda\". Available platform names are: ")

julia> x = Reactant.to_rarray([3])
1-element ConcreteRArray{Int64, 1}:
 3

julia> T = Any[nothing]
1-element Vector{Any}:
 nothing

julia> function ip(m, T)
           @allowscalar m[1] = 2
           T[1] = m
           return m
       end
ip (generic function with 1 method)

julia> @code_hlo ip(x, T)
module {
  func.func @main(%arg0: tensor<1xi64>) -> tensor<1xi64> {
    %c = stablehlo.constant dense<2> : tensor<1xi64>
    %c_0 = stablehlo.constant dense<0> : tensor<1x1xi64>
    %0 = "stablehlo.scatter"(%arg0, %c_0, %c) <{scatter_dimension_numbers = #stablehlo.scatter<inserted_window_dims = [0], scatter_dims_to_operand_dims = [0], index_vector_dim = 1>}> ({
    ^bb0(%arg1: tensor<i64>, %arg2: tensor<i64>):
      stablehlo.return %arg2 : tensor<i64>
    }) : (tensor<1xi64>, tensor<1x1xi64>, tensor<1xi64>) -> tensor<1xi64>
    return %0 : tensor<1xi64>
  }
}
@wsmoses
Copy link
Member

wsmoses commented Feb 2, 2025

There's a few ways this can be done

  1. Scatter -> dynamicupdateslice
  2. scatter of whole size -> replace (should be subsumed by 1)

@avik-pal
Copy link
Collaborator

avik-pal commented Feb 6, 2025

  1. Scatter -> dynamicupdateslice

we have this. we need to make sure it supports inserted_window_dims = [0]. (we could also potentially fix this on reactant end to not emit inserted_window_dims in the first place)

@wsmoses
Copy link
Member

wsmoses commented Feb 6, 2025

eh ideally we can optimize this (better long term anyways)

@avik-pal avik-pal changed the title Missing optimization Scatter Optimizations with Window Dims specified Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants