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

[Numpy] basic slicing in symbolic interface #15663

Closed
wants to merge 1 commit into from

Conversation

mikemwx
Copy link
Contributor

@mikemwx mikemwx commented Jul 26, 2019

Description

Implement basic slicing in symbolic interface

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Add npx_slice to support the same kind of slicing in ndarray

  • Add npx_reshape to support reshape with special flags

    • -1 to infer this dimension from the other given dimensions
    • -2 copy the current dimension from the input to the output
    • -3 skip the current dimension if and only if the current dimension is of size 1, report an error otherwise
    • -4 copy all remaining dimensions from the input to the output
    • -5 use the product of the next two consecutive dimensions in the output
    • -6 split current dimension in the output into the next two dimensions in the input
  • Implement basic slicing in _symbol.py : __getitem__, basic slicing means slicing with

    • an integer
    • a pyslice
    • a tuple of integers and pyslices

A flag _output_is_list is added to symbol class in the frontend to differentiate the cases in which a symbol with only one output Node is conceptually a list, eg: split(x, 1)

  • Overload the Group function in Symbol
  • Overload the save, save_json_string, load, load_json_string to specially take care of the newly added flag

Comments

Based on the current implementation, any operator that generates a list-like output should register their name in the list python/mxnet/base.py:_NP_OUTPUT_IS_LIST_OPERATORS

Thank @reminisce and @haojin2 for reviewing

@abhinavs95
Copy link
Contributor

@mxnet-label-bot add [numpy, pr-awaiting-review]

@marcoabreu marcoabreu added Numpy pr-awaiting-review PR is waiting for code review labels Jul 26, 2019
@mikemwx mikemwx force-pushed the np_symbolic_basic_slicing branch 2 times, most recently from 4f6b284 to 2b8318a Compare August 1, 2019 06:32
Syntax fixes

Minor naming error fix

Add the new flag in cython version of  imperative_invoke and symbol_creator

Syntax fix for test_numpy_op

Minor syntax fix

Fix the front end constructor of _Symbol

remove mshadow follow the master
@zoeygxy zoeygxy mentioned this pull request Aug 6, 2019
6 tasks
@mikemwx
Copy link
Contributor Author

mikemwx commented Aug 15, 2019

#15905 A new PR is made to master branch

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Numpy pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants