Skip to content

Conversation

@ejguan
Copy link
Contributor

@ejguan ejguan commented Nov 10, 2020

Stack from ghstack:

Fixes #45896

  • API
  • constructor(OrderedDict/vector of pair)
  • clear()
  • items()
  • keys()
  • pop(string key)
  • update(OrderedDict/vector of pair/ModuleDict)
  • values()
  • Iterator: begin/end
  • size()
  • empty()
  • contains(string key)
  • clone()
  • pretty_print(stream)
  • operator [string key]
  • at(string key)
  • Add tests

Differential Revision: D24872641

[ghstack-poisoned]
ejguan added a commit that referenced this pull request Nov 10, 2020
ghstack-source-id: a0a2a0f
Pull Request resolved: #47707
@ejguan ejguan linked an issue Nov 10, 2020 that may be closed by this pull request
@dr-ci
Copy link

dr-ci bot commented Nov 10, 2020

💊 CI failures summary and remediations

As of commit 8716117 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 16 times.

ejguan added a commit that referenced this pull request Nov 13, 2020
ghstack-source-id: 3a46a61
Pull Request resolved: #47707
@codecov
Copy link

codecov bot commented Nov 14, 2020

Codecov Report

Merging #47707 (8716117) into gh/ejguan/8/base (3846e35) will increase coverage by 0.01%.
The diff coverage is 93.26%.

@@                 Coverage Diff                  @@
##           gh/ejguan/8/base   #47707      +/-   ##
====================================================
+ Coverage             81.26%   81.27%   +0.01%     
====================================================
  Files                  1839     1841       +2     
  Lines                198808   199016     +208     
====================================================
+ Hits                 161554   161746     +192     
- Misses                37254    37270      +16     

@ejguan ejguan requested a review from zou3519 November 16, 2020 14:12
Copy link
Contributor

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not many comments from me but I don't know much about the C++ API

Comment on lines +95 to +97
/// `reset()` is empty for `ModuleDict`, since it does not have parameters of
/// its own.
void reset() override {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glaringlee how is reset() used in the C++ API? If it doesn't make sense to call reset() for ModuleDict, would it be better to raise an error?

Copy link
Contributor

@glaringlee glaringlee Nov 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zou3519
Can not raise an error, since this is called in cloneable.h when cloning, even it is empty, it will be called. If reset() is not used here, leaving it empty is fine. I somehow recalled that reset() in this moduledict case should do something special, will update here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zou3519 I reviewed a bit, clone() is also overridden in this impl, so reset() is actually useless. I think it is fine to just leave it as blank, this is kinda convention in c++ API impls.

@ejguan
Copy link
Contributor Author

ejguan commented Nov 17, 2020

And, I am wondering if we need another API of ptr(const std::string& key)? @glaringlee

@glaringlee
Copy link
Contributor

And, I am wondering if we need another API of ptr(const std::string& key)? @glaringlee

I did not see any usage for ptr at the moment, but you can add it if it is not heavy work.

Fixes #45896
- [x] API
* constructor(OrderedDict/vector of pair)
* clear()
* items()
* keys()
* pop(string key)
* update(OrderedDict/vector of pair/ModuleDict)
* values()
* Iterator: begin/end
* size()
* empty()
* contains(string key)
* clone()
* pretty_print(stream)
* operator [string key]
* at(string key)
- [x] Add tests

Differential Revision: [D24872641](https://our.internmc.facebook.com/intern/diff/D24872641)

[ghstack-poisoned]
ejguan added a commit that referenced this pull request Nov 17, 2020
ghstack-source-id: e99072d
Pull Request resolved: #47707
@ejguan ejguan requested a review from glaringlee November 17, 2020 19:46
Copy link
Contributor

@glaringlee glaringlee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment, I should mention earlier, sry.
Otherwise, all looks good to me.

Fixes #45896
- [x] API
* constructor(OrderedDict/vector of pair)
* clear()
* items()
* keys()
* pop(string key)
* update(OrderedDict/vector of pair/ModuleDict)
* values()
* Iterator: begin/end
* size()
* empty()
* contains(string key)
* clone()
* pretty_print(stream)
* operator [string key]
* at(string key)
- [x] Add tests

Differential Revision: [D24872641](https://our.internmc.facebook.com/intern/diff/D24872641)

[ghstack-poisoned]
ejguan added a commit that referenced this pull request Nov 18, 2020
ghstack-source-id: d442d2b
Pull Request resolved: #47707
@glaringlee glaringlee self-requested a review November 18, 2020 21:27
Copy link
Contributor

@glaringlee glaringlee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now. Please sync this latest version on phabricator before landing. thx

@facebook-github-bot
Copy link
Contributor

@ejguan merged this pull request in c542614.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C++ ModuleDict

5 participants