Skip to content
This repository has been archived by the owner on Jan 20, 2020. It is now read-only.

fix group symbols cached bug #11

Merged
merged 1 commit into from
Nov 20, 2016
Merged

fix group symbols cached bug #11

merged 1 commit into from
Nov 20, 2016

Conversation

ZihengJiang
Copy link
Collaborator

@ZihengJiang ZihengJiang commented Nov 18, 2016

  • change the interface of Session.Run(...)
  • use a hash function to generate the hash value of the vector of Symbols*

@ZihengJiang ZihengJiang changed the title fix group symbols cached problem fix group symbols cached bug Nov 18, 2016
uint64_t hash_value = hash_symbols(syms);

if (cached_execs_.count(hash_value) != 0) {
auto& entry = cached_execs_.at(hash_value);
const nnvm::Symbol& s = entry.exec->symbol();
bool stale_exec = (s.outputs.size() != sym->outputs.size());
Copy link
Owner

Choose a reason for hiding this comment

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

This check is not enough, need to check the ptr of all symbols

Copy link
Collaborator Author

@ZihengJiang ZihengJiang Nov 19, 2016

Choose a reason for hiding this comment

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

@tqchen looks like this requires us to save the pointer of symbols before. Do you mean there is a condition that two vector of symbols have the same hash value and also can pass the stale executor check below?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes. thatiswhat I mean

for (uint32_t i = 0; i < syms.size(); ++i) {
sym_arr.push_back(*syms[i]);
}
*new_sym = nnvm::Symbol::CreateGroup(sym_arr);
Copy link
Owner

Choose a reason for hiding this comment

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

simply write nnvm::Symbol new_sym instead of pointer


// compute the hash value of the input symbols
uint64_t hash_value = syms.size();
for (nnvm::Symbol* i : syms) {
Copy link
Owner

Choose a reason for hiding this comment

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

Let us add a new function called FindCachedExecs


// compute the hash value of the input symbols
uint64_t hash_value = syms.size();
for (nnvm::Symbol* i : syms) {
Copy link
Owner

Choose a reason for hiding this comment

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

Use pointer of nodes as hash keys, this removes the need of symbol pointers

@@ -67,6 +67,8 @@ class TorchSession : public Session {
private:
// entry to store cached executor
struct ExecEntry {
// cached symbols
std::vector<nnvm::Symbol*> cached_symbols_;
Copy link
Owner

Choose a reason for hiding this comment

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

Simply use nnvm::Symbol, use the node pointers as key

Copy link
Collaborator Author

@ZihengJiang ZihengJiang Nov 20, 2016

Choose a reason for hiding this comment

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

do you mean group symbol? then use the pointer of output node?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the output node will change, so it should be symbol.outputs[0].inputs nodes?

Copy link
Owner

Choose a reason for hiding this comment

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

the output node won't change, as they are refering back to the same NodePtr

@ZihengJiang ZihengJiang reopened this Nov 20, 2016
@ZihengJiang
Copy link
Collaborator Author

@tqchen

  • use pointer of nodes as hash value
  • I recommend to add a cached symbol in ExecEntry, due to the exec.symbol() maybe will be changed after we change the graph

@tqchen tqchen merged commit 29b464c into tqchen:master Nov 20, 2016
@ZihengJiang ZihengJiang deleted the fixbug branch November 20, 2016 19:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants