Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Julia: deprecate mx.empty, replace it with UndefInitializer constructor #13934

Merged
merged 1 commit into from
Jan 21, 2019

Commits on Jan 19, 2019

  1. Julia: deprecate mx.empty, replace it with UndefInitializer

    In Julia 0.7+, constructing a uninitialized array is provided via
    the APIs:
            - `Array{T,N}(undef, dims...)`
            - `Array{T,N}(undef, dims)`
            - `Array{T}(undef,   dims...)`
            - `Array{T}(undef,   dims)`
    
    There is an API `mx.empty(dims...)` serving for this purpose.
    
    This PR proposes that deprecating the original API `mx.empty` and
    provide the functionality with the API design similar to Julia's Base.
    
            - `NDArray{T,N}(undef, dims...)`
            - `NDArray{T,N}(undef, dims)`
            - `NDArray{T}(undef,   dims...)`
            - `NDArray{T}(undef,   dims)`
            - `NDArray(undef,      dims...)`
            - `NDArray(undef,      dims)`
    
    e.g.
    
    ```julia
    julia> NDArray{Int,2}(undef, 5, 2)
    5×2 NDArray{Int64,2} @ CPU0:
     94290755905104  94290752678143
     94290752660544     68719476760
     94290752674408  94290737734368
     94290752660544              18
     94290752674408              18
    
    julia> NDArray(undef, 5, 2)  # default type is `mx.MX_float`
    5×2 NDArray{Float32,2} @ CPU0:
     -29112.406f0       5.2029858f-8
          3.0763f-41    6.7375383f-10
          1.7613131f19  0.0f0
          4.840456f30   0.0f0
          4.4262863f30  0.0f0
    ```
    
    - The original `mx.empty` APIs are still functional.
      If user invokes them, a deprecation warning will be popped up.
    iblislin committed Jan 19, 2019
    Configuration menu
    Copy the full SHA
    1c60330 View commit details
    Browse the repository at this point in the history