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

Commit

Permalink
NUP-2475: Add sparse link validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lscheinkman committed Mar 13, 2018
1 parent fb596b5 commit 2f027a7
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/nupic/engine/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,23 @@ void Network::link(const std::string &srcRegionName,
<< " does not exist on region " << destRegionName;
}

NTA_CHECK(srcOutput->getDataType() == destInput->getDataType())
<< "Network::link -- Mismatched data types."
<< BasicType::getName(srcOutput->getDataType())
<< " != " << BasicType::getName(destInput->getDataType());
// Validate link data types
if (srcOutput->isSparse() == destInput->isSparse()) {
NTA_CHECK(srcOutput->getDataType() == destInput->getDataType())
<< "Network::link -- Mismatched data types."
<< BasicType::getName(srcOutput->getDataType())
<< " != " << BasicType::getName(destInput->getDataType());
} else if (srcOutput->isSparse()) {
// Sparse to dense: unit32 -> bool
NTA_CHECK(srcOutput->getDataType() == NTA_BasicType_UInt32 &&
destInput->getDataType() == NTA_BasicType_Bool)
<< "Network::link -- Sparse to Dense link: source must be uint32 and "
"destination must be boolean";
} else if (destInput->isSparse()) {
// Dense to sparse: NTA_BasicType -> uint32
NTA_CHECK(destInput->getDataType() == NTA_BasicType_UInt32)
<< "Network::link -- Dense to Sparse link: destination must be uint32";
}

// Create the link itself
auto link =
Expand Down

0 comments on commit 2f027a7

Please sign in to comment.