From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Tue, 2 Oct 2018 04:48:57 +0000 (+0900) Subject: [enco] Get Code from Session (#1720) X-Git-Tag: nncc_backup~1648 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ce2b290e08e0f2fc238fc95eca001cb163372d13;p=platform%2Fcore%2Fml%2Fnnfw.git [enco] Get Code from Session (#1720) With this commit, enco Backend class no longer declares Code variable. Instead, it accesses the Code entity through Session. Signed-off-by: Jonghyun Park --- diff --git a/contrib/enco/core/src/Backend.cpp b/contrib/enco/core/src/Backend.cpp index 64b8a36..c97ee5f 100644 --- a/contrib/enco/core/src/Backend.cpp +++ b/contrib/enco/core/src/Backend.cpp @@ -79,16 +79,14 @@ private: void BackendImpl::compile(coco::Module *m, coco::Data *d) { - make_session(m, d); - - Code code{m, d}; + auto sess = make_session(m, d); // As explained below, the current implementation does not work if there is a pair of input/ouput // that share the same bag as their underlying bag. // // This DuplicatePass creates a copy of such bags in order to eliminate such a pair. DuplicatePass duplicate; - duplicate.runOnCode(&code); + duplicate.runOnCode(code(sess)); // The current implementation will assign memory region for each bag as follows: // Bind input bag to the region provided by Network_input_bind @@ -97,42 +95,42 @@ void BackendImpl::compile(coco::Module *m, coco::Data *d) // // Note that this scheme does not work if there is a pair of input/output // that share the same bag as their underlying bag - assert(!has_inout_bag(code.module())); + assert(!has_inout_bag(code(sess)->module())); - unify_feature(&code); + unify_feature(code(sess)); AvgPoolRewritePass avgpool_rewrite; - avgpool_rewrite.runOnCode(&code); + avgpool_rewrite.runOnCode(code(sess)); // Insert data ordering if necessary NormalizePass normalize; - normalize.runOnCode(&code); + normalize.runOnCode(code(sess)); - eliminate_indirect_copy(&code); - reduce_identical_object(&code); - reduce_duplicated_object(&code); + eliminate_indirect_copy(code(sess)); + reduce_identical_object(code(sess)); + reduce_duplicated_object(code(sess)); // Eliminate dead object // // NOTE Dead Object Elimination (DOE) is performed before Copy lowering // in order to reduce compilation overhead. - eliminate_dead_object(&code); + eliminate_dead_object(code(sess)); // Lower Copy as Shuffle - lower_copy(&code); + lower_copy(code(sess)); - generate_bypass_shuffle(&code); + generate_bypass_shuffle(code(sess)); - eliminate_dead_bag(&code); + eliminate_dead_bag(code(sess)); // Split instructions into a set of phases (each block serves as a phase) SplitPass split; - split.runOnCode(&code); + split.runOnCode(code(sess)); // TODO Run various transforms over enco::Code std::ofstream ofs{_prefix + ".cpp"}; - ofs << CppCode{&code} << std::endl; + ofs << CppCode{code(sess)} << std::endl; } } // namespace enco