Skip to content

Conversation

Keno
Copy link
Contributor

@Keno Keno commented Jan 29, 2019

  1. Parameterize OneHotVector on Integer type, to avoid using more memory
    than required for vectors of them.
  2. Switch OneHotMatrix from storing a vector of OneHotVectors to only storing
    the data and the size of the vector (reconstructing the vector locally), thus
    saving half the memory required and eliminating a transpose operation for
    matmul with OneHotMatrix on TPU.

1. Parameterize OneHotVector on Integer type, to avoid using more memory
   than required for vectors of them.
2. Switch OneHotMatrix from storing a vector of OneHotVectors to only storing
   the data and the size of the vector (reconstructing the vector locally), thus
   saving half the memory required and eliminating a transpose operation for
   matmul with OneHotMatrix on TPU.
@KristofferC
Copy link
Contributor

This no longer works:

julia>  y = Flux.onehotbatch(1:3, 1:10)
10×3 Flux.OneHotMatrix{Array{Int64,1}}:
  true  false  false
 false   true  false
 false  false   true
 false  false  false
 false  false  false
 false  false  false
 false  false  false
 false  false  false
 false  false  false
 false  false  false

julia> gpu(y)
ERROR: MethodError: no method matching Flux.OneHotMatrix(::Int64, ::CuArray{Float32,1})
Closest candidates are:
  Flux.OneHotMatrix(::Int64, ::A<:(AbstractArray{#s21,1} where #s21<:Integer)) where A<:(AbstractArray{#s21,1} where #s21<:Integer) at C:\Users\Kristoffer\.julia\dev\Flux\src\onehot.jl:18

@Keno
Copy link
Contributor Author

Keno commented Feb 1, 2019

Yeah, I need to fix more things here. Also have a typo right now. Will push an updated version in a few days.

@ToucheSir
Copy link
Member

@darsnack I assume #1448 mostly obviates this?

@darsnack
Copy link
Member

darsnack commented Feb 12, 2021

Yeah I think so. Safe to close.

@CarloLucibello CarloLucibello deleted the kf/onehotmmemory branch April 7, 2022 07:05
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

Successfully merging this pull request may close these issues.

5 participants