-
Notifications
You must be signed in to change notification settings - Fork 124
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
keep_dims option #531
keep_dims option #531
Conversation
I cannot immediately say whether or not it will impact thing in CGraph, do we have corresponding unit tests for cgraph? @jzstark |
@pvdhove Pierre can also comment if there is anything in his mind. Pierre did a lot of work on CGraph and is very familiar with it as well. |
From what I recall, here are a few changes that would need to be made if you want the extra argument to have the expected behaviour with CGraph (all files that I mention are in
For some more context about optimisation: what I had chosen in |
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.
I think that before merging, the points addressed by @pvdhove for CGraph should be integrated to the PR
I have just pushed some changes that shall allow users to use the There are several aspects of the code that I do not fully understand, and for To infer shape in In Also, do we have a unit test for the operations in CGraph? |
Everything looks good to me! Your interpretation of the For the optimisation part, I just don't understand why To my knowledge, there are no unit tests for CG, only examples (both in the |
oh right, I forgot about the optimization part. I meant to ask. I didn't really understand what In any case, we should probably open an issue to add unit tests for operations in |
Thanks both for looking into it! I agree that a new issue for the unit tests would be good. @tachukao given that you are there, it may be a good idea to add some meta comments on why you are calling certain functions instead of others directly in the code (e.g. the optimisation in pattern_xxx or _eval_map) |
Yes, basically the optimization part performs a DFS of the computation graph before the evaluation of its nodes, and implements a few different techniques to make things more efficient: for instance, removing useless operations, pre-computing the parts of the graph that do not depend on the inputs (so that if the graph is evaluated multiple times with different inputs, those parts of the graph are only computed once), changing the order of the operations to make them faster or more precise, merging operations that can be performed in one go, etc. The
Yes!
The various operations reuse the code written outside of the CGraph module, so I guess that is why unit tests with CG for specific operations have not seemed essential. However, it would be really good if there were unit tests for specific CG operations (the optimizations, creating the graph, manipulating the graph, etc.). |
As Pierre mentioned, yes the real operations of CG are provided by the module we plug in, so they need to be tested with a specific backend. As you all said, the generic graph operations shall be tested at least, totally agree. |
@mseri I've just add some comments. Since we aren't do any optimization for these operations, we are going with the defaults mostly |
@ryanrhymes @mseri shall we merge this if there's nothing else that needs changing right away? |
The PR looks all good to me. Unit tests of CG is a separate issue we can take care of that in future. @mseri do you have further comments on this? |
CHANGES: * various documentation improvements (thanks @pveber, @UnixJunkie, @Fourchaux) * Fix use of access operators (owlbarn/owl#543) * Upgrade to ocamlformat 0.15.0 (thanks @gpetiot owlbarn/owl#535) * keep_dims option (owlbarn/owl#531) * stats: fix infinite loop in ecdf * Use Fun.protect to ensure all file descriptors are being closed * owl_ndarray_maths: improve user experience in case of errors * owl_io: close file descriptors also in case of errors * owl_dense_ndarray_generic: fix error on printing 0-ary arrays * fixed bug in sub forward mode (owlbarn/owl#533) * Add stack to Algodiff (owlbarn/owl#528) * added log_sum_exp to Ndarray and Algodiff (owlbarn/owl#527) * added single-precision and double-precision Bessel functions to Ndarray (owlbarn/owl#526) * Fixes owlbarn/owl#518 by introducing another `/` to resolve data directory (@jotterbach owlbarn/owl#519) * Graph Slice node (resolves owlbarn/owl#483) (@mreppen owlbarn/owl#517) * Graph subnetwork: Multiple outputs (@mreppen owlbarn/owl#515) * Added kron and swap to Algodiff operations (owlbarn/owl#512) * various other small fixes
As discussed in #529, I've added the
keep_dims
option forsum
,mean
,var
,std
,sem
,min
,max
,log_sum_exp
,prod
and others.The default option for
keep_dims
istrue
and is thus backward compatible.@jzstark @ryanrhymes I'm not quite sure how
keep_dims
changes the computation graph in e.g.,owl_base_computation_operation.ml
. I've ignored thekeep_dims
option for now. Any ideas?