This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Julia: deprecate mx.empty
, replace it with UndefInitializer
constructor
#13934
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
changed the title
Julia: deprecate
Julia: deprecate Jan 19, 2019
mx.empty
, replace it with UndefInitializer
mx.empty
, replace it with UndefInitializer
constructor
marcoabreu
approved these changes
Jan 20, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is backwards compatible, right?
Yeah, for instance: julia> mx.empty(2, 3)
┌ Warning: `mx.empty(dims...)` is deprecated, use `NDArray(undef, dims...)` instead.
└ @ MXNet.mx ~/.julia/dev/MXNet/src/deprecated.jl:193
2×3 NDArray{Float32,2} @ CPU0:
-2.690016f-37 -2.7809797f-37 4.5f-44
3.0819f-41 3.0819f-41 0.0f0
julia> mx.empty((2, 3))
┌ Warning: `mx.empty(dims, ctx)` is deprecated, use `NDArray(undef, dims; ctx = ctx)` instead.
└ @ MXNet.mx ~/.julia/dev/MXNet/src/deprecated.jl:187
2×3 NDArray{Float32,2} @ CPU0:
-3.1642064f-37 1.7975115f19 8.0f-44
3.0819f-41 0.00017281323f0 0.0f0 By Julia's convention, any API changes will pop a deprecation warning (we call it depwarn in Julia community) to help user update their code. |
Awesome, thanks. Feel free to merge whenever you are ready |
jessr92
pushed a commit
to jessr92/incubator-mxnet
that referenced
this pull request
Jan 27, 2019
…he#13934) 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.
stephenrawls
pushed a commit
to stephenrawls/incubator-mxnet
that referenced
this pull request
Feb 16, 2019
…he#13934) 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.
haohuanw
pushed a commit
to haohuanw/incubator-mxnet
that referenced
this pull request
Jun 23, 2019
…he#13934) 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.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Julia 0.7+, constructing an 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
andprovide 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.
mx.empty
APIs are still functional.If user invokes them, a deprecation warning will be popped up.
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.