forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cms-sw#40284 from riga/use_global_session_DeepMET
Move TF session in DeepMETProducer to global cache
- Loading branch information
Showing
6 changed files
with
112 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Tests for interacting with the SessionCache. | ||
* | ||
* Author: Marcel Rieger | ||
*/ | ||
|
||
#include <stdexcept> | ||
#include <cppunit/extensions/HelperMacros.h> | ||
|
||
#include "PhysicsTools/TensorFlow/interface/TensorFlow.h" | ||
|
||
#include "testBase.h" | ||
|
||
class testSessionCache : public testBase { | ||
CPPUNIT_TEST_SUITE(testSessionCache); | ||
CPPUNIT_TEST(checkAll); | ||
CPPUNIT_TEST_SUITE_END(); | ||
|
||
public: | ||
std::string pyScript() const override; | ||
void checkAll() override; | ||
}; | ||
|
||
CPPUNIT_TEST_SUITE_REGISTRATION(testSessionCache); | ||
|
||
std::string testSessionCache::pyScript() const { return "createconstantgraph.py"; } | ||
|
||
void testSessionCache::checkAll() { | ||
std::string pbFile = dataPath_ + "/constantgraph.pb"; | ||
|
||
tensorflow::setLogging(); | ||
|
||
// load the graph and the session | ||
tensorflow::SessionCache cache(pbFile); | ||
CPPUNIT_ASSERT(cache.graph.load() != nullptr); | ||
CPPUNIT_ASSERT(cache.session.load() != nullptr); | ||
|
||
// get a const session pointer | ||
const tensorflow::Session* session = cache.getSession(); | ||
CPPUNIT_ASSERT(session != nullptr); | ||
|
||
// cleanup | ||
cache.closeSession(); | ||
CPPUNIT_ASSERT(cache.graph.load() == nullptr); | ||
CPPUNIT_ASSERT(cache.session.load() == nullptr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters