-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Conversation
0f449e4
to
cb574c5
Compare
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.
Please apply these changes
// scalastyle:off | ||
val absClassFunctions = getSymbolNDArrayMethods(isSymbol) | ||
// TODO: Add Filter to the same location in case of refactor | ||
val absFuncs = absClassFunctions.filter(f => f.name.startsWith("sample") || f.name.startsWith("random")) |
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.
_sample
and _random
?
scala-package/macros/src/main/scala/org/apache/mxnet/APIDocGenerator.scala
Show resolved
Hide resolved
@@ -97,34 +117,41 @@ private[mxnet] object SymbolImplMacros { | |||
val newSymbolFunctions = { | |||
if (isContrib) symbolFunctions.filter( | |||
func => func.name.startsWith("_contrib_") || !func.name.startsWith("_")) | |||
else symbolFunctions.filter(!_.name.startsWith("_")) | |||
else symbolFunctions.filter(f => !f.name.startsWith("_") && |
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.
Let's think of how we can move the filter method out of this typedAPIImpl
. So different method generator pass in different filters.
@mdespriee Firstly for unit test, there are tests covers in Python on these operators. In that case we decide not to test them on Scala end.
For this question, let me consult with people working on Python. Please also consider adding NDArray with these operators (in NDArrayAPI) |
Hi @mdespriee , I have created a JIRA ticket for you: https://issues.apache.org/jira/browse/MXNET-918. You can put it on the title so people know what issue it is related. |
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.
As mentioned, _random_
and random_
operators are different in backend, the major difference are the accepted input for the frontend, usually can either be a static type or NDArray.
scala-package/macros/src/main/scala/org/apache/mxnet/APIDocGenerator.scala
Outdated
Show resolved
Hide resolved
scala-package/macros/src/main/scala/org/apache/mxnet/NDArrayMacro.scala
Outdated
Show resolved
Hide resolved
@@ -91,69 +114,74 @@ private[mxnet] object NDArrayMacro { | |||
val newNDArrayFunctions = { | |||
if (isContrib) ndarrayFunctions.filter( | |||
func => func.name.startsWith("_contrib_") || !func.name.startsWith("_")) | |||
else ndarrayFunctions.filterNot(_.name.startsWith("_")) | |||
else ndarrayFunctions.filterNot(f => f.name.startsWith("_") && | |||
!f.name.startsWith("sample_") && !f.name.startsWith("random_")) |
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.
b1c26b6
to
7f845ef
Compare
Thanks for your contribution @mdespriee |
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.
Firstly congratulation on your progress! I am pretty impressed on the progress you have made in here.
However, I also hold a little concern in here: Since the _random
and _sample
can take both Symbol/NDArray or a static type as param. This should catch the type diff. But it doesn't catch. I am curious what types does Macros generated in here.
scala-package/macros/src/main/scala/org/apache/mxnet/APIDocGenerator.scala
Outdated
Show resolved
Hide resolved
scala-package/macros/src/main/scala/org/apache/mxnet/APIDocGenerator.scala
Show resolved
Hide resolved
ndarrayFunctions.filter(f => f.name.startsWith("_sample_") || f.name.startsWith("_random_")) | ||
|
||
val functionDefs = rndFunctions.map(f => buildTypeSafeFunction(c)(f)) | ||
structGeneration(c)(functionDefs, annottees: _*) |
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.
The possible way to do it is maybe apply some regex pattern as a param to reconstruct the way you want to represent this.
@@ -97,34 +117,40 @@ private[mxnet] object SymbolImplMacros { | |||
val newSymbolFunctions = { | |||
if (isContrib) symbolFunctions.filter( | |||
func => func.name.startsWith("_contrib_") || !func.name.startsWith("_")) | |||
else symbolFunctions.filter(!_.name.startsWith("_")) | |||
else symbolFunctions.filter(f => !f.name.startsWith("_")) |
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.
Use .filterNot
in here, Sync with NDArray
@lanking520. Underscore removed. We now have this kind of signatures:
and
I don't think we can go further. If remove both |
@mdespriee Firstly I think we have a collide operators.
|
Thanks for your contribution @mdespriee. Please have a look at @lanking520's feedback. |
@mdespriee Have you had a chance to look at @lanking520 's feedback? Requesting an update from you on this. |
Hi,
I've been busy the 2 past weeks (spark summit...) I noticed @lanking520
about that.
I'll probably be able to work on it this week. This PR is not dead :-)
Mathieu
Le mar. 9 oct. 2018 à 09:01, Rakesh Vasudevan <[email protected]> a
écrit :
… @mdespriee <https://github.com/mdespriee> Have you had a chance to look
at @lanking520 <https://github.com/lanking520> 's feedback? Requesting an
update from you on this.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12489 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABhFNMShE8rC0j-fVtDh3yxRUmtfguy9ks5ujEmsgaJpZM4WgCDH>
.
|
@mdespriee Good to see you back! |
@lanking520
|
@mdespriee Firstly thanks for coming back to maintain this PR! I see your point, is there a mapping can be applied to these operators? If yes as they are just the difference like that, we can apply something in Macros end to make it change. Apart from that, I think you can extend https://github.com/apache/incubator-mxnet/blob/master/scala-package/core/src/main/scala/org/apache/mxnet/Random.scala this class to support Random with your Macros design |
Can we add a gist of the generated code? Also, is there a reason that we're adding a new NDArray.random as an api instead of extending NDArray.api (same for Symbol)? |
@andrewfayres here is what we are trying to do: https://mxnet.incubator.apache.org/api/python/ndarray/random.html. In NDArray API we already have some random generation function, but a Random namespace would be great since it is compatible with both NDArray/Float. |
0b75b87
to
d512452
Compare
@lanking520 Here is an updated PR.
I'm investigating that. Any hint welcome !
|
@mdespriee thanks for your effort to refactor the code and I really appreciate your time spent on it. The issue shown above is the mismatch on the parameter. It can be caused by
I know this may introduce more work to you but I think this could be the best solution. |
Following @lanking520 comment, I split the work in 2 PRs:
|
Description
Introduce Symbol.random and NDArray.random modules in scala API
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments
Is there any JIRA mentioning this feature ?Only implemented for Symbol. Adding the same for NDArray seems quite straightforward. Tell me if I should to it in the same PR or in a separateI moved functions from Symbol.api to Symbol.random. Is it OK ?=> What are your recommendations on this ?