Region* Network::addRegionFromBundle(const std::string& name, const std::string& nodeType, const Dimensions& dimensions, const std::string& bundlePath, const std::string& label) { if (regions_.contains(name)) NTA_THROW << "Invalid saved network: two or more instance of region '" << name << "'"; if (! Path::exists(bundlePath)) NTA_THROW << "addRegionFromBundle -- bundle '" << bundlePath << " does not exist"; BundleIO bundle(bundlePath, label, name, /* isInput: */ true ); Region *r = new Region(name, nodeType, dimensions, bundle, this); regions_.add(name, r); initialized_ = false; // In the normal use case (deserializing a network from a bundle) // this default phase will immediately be overridden with the // saved phases. Having it here makes it possible for user code // to safely call addRegionFromBundle directly. setDefaultPhase_(r); return r; }
Region* Network::addRegion(const std::string& name, const std::string& nodeType, const std::string& nodeParams) { if (regions_.contains(name)) NTA_THROW << "Region with name '" << name << "' already exists in network"; Region *r = new Region(name, nodeType, nodeParams, this); regions_.add(name, r); initialized_ = false; setDefaultPhase_(r); return r; }
Region* Network::addRegionFromProto(const std::string& name, RegionProto::Reader& proto) { if (regions_.contains(name)) { NTA_THROW << "Cannot add region with name '" << name << "' that is already in used."; } auto region = new Region(name, proto, this); regions_.add(name, region); initialized_ = false; // In the normal use case (deserializing a network) // this default phase will immediately be overridden with the // saved phases. Having it here makes it possible for user code // to safely call addRegionFromProto directly. setDefaultPhase_(region); return region; }