Skip to content

Commit

Permalink
(trivial) add const to some PlaceholderBindings params (pytorch#3648)
Browse files Browse the repository at this point in the history
Summary:
For the methods of PlaceholderBindings that take a list, we don't ever modify the params and they can be const. Most usefully this lets you call `allocate(module->getPlaceholders())` if the module is const.

Documentation: n/a
Pull Request resolved: pytorch#3648

Test Plan: build & ran tests

Differential Revision: D18045221

Pulled By: nickgg

fbshipit-source-id: bbfc93aea01c113dde658b06d87cca7cec9c5224
  • Loading branch information
nickgg authored and facebook-github-bot committed Oct 21, 2019
1 parent 2bc5881 commit 65d441c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions include/glow/Graph/PlaceholderBindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ class PlaceholderBindings final {
/// Allocates zero-initialized backing tensors to all placeholders in \p lst
/// that are not currently allocated in the bindings.
/// \returns the number of tensors that were allocated.
unsigned allocate(std::list<Placeholder *> &lst);
unsigned allocate(const std::list<Placeholder *> &lst);

/// \returns the first placeholder in \p list that is not allocated by this
/// bindings. This method returns null if all placeholders in the list are
/// allocated.
Placeholder *getFirstUnallocated(std::list<Placeholder *> &lst) const;
Placeholder *getFirstUnallocated(const std::list<Placeholder *> &lst) const;

/// \returns True if \p P is a registered Placeholder.
size_t count(Placeholder *P) const;
Expand Down
6 changes: 3 additions & 3 deletions lib/Graph/PlaceholderBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Tensor *PlaceholderBindings::allocate(Placeholder *P) {
return T;
}

unsigned PlaceholderBindings::allocate(std::list<Placeholder *> &lst) {
unsigned PlaceholderBindings::allocate(const std::list<Placeholder *> &lst) {
unsigned allocated = 0;
// For each placeholder in the list:
for (Placeholder *P : lst) {
Expand All @@ -195,8 +195,8 @@ unsigned PlaceholderBindings::allocate(std::list<Placeholder *> &lst) {
return allocated;
}

Placeholder *
PlaceholderBindings::getFirstUnallocated(std::list<Placeholder *> &lst) const {
Placeholder *PlaceholderBindings::getFirstUnallocated(
const std::list<Placeholder *> &lst) const {
// For each placeholder in the list:
for (Placeholder *P : lst) {
// If we found an unallocated placeholder then return it.
Expand Down

0 comments on commit 65d441c

Please sign in to comment.