Skip to content

Commit

Permalink
Add more comments about cinn flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
wzzju committed Nov 2, 2021
1 parent 8cb6b19 commit 6560f06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion paddle/fluid/framework/paddle2cinn/cinn_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ const CinnCompiledObject& CinnCompiler::Compile(
exist = cache_.count(cur_key) != 0;
}
if (!exist) {
real_compiled_num_++;
auto compiled_res = CompileGraph(graph, input_tensors, target);
AutoWRLock w_guard{&rwlock_};
real_compiled_num_++;
cache_[cur_key] = std::move(compiled_res);
}
AutoRDLock guard{&rwlock_};
Expand Down
16 changes: 7 additions & 9 deletions paddle/fluid/framework/paddle2cinn/cinn_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <atomic>
#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <unordered_map>

Expand Down Expand Up @@ -67,16 +66,15 @@ class CinnCompiler {
const ir::Graph& FindGraph(const std::string& key) const;

void Clear() {
AutoWRLock guard{&rwlock_};
graphs_.clear();
cache_.clear();
{
AutoWRLock guard{&rwlock_};
graphs_.clear();
cache_.clear();
}
real_compiled_num_ = 0;
}

std::int64_t real_compiled_num() const {
AutoRDLock guard{&rwlock_};
return real_compiled_num_;
}
std::int64_t real_compiled_num() const { return real_compiled_num_; }

~CinnCompiler() = default;

Expand All @@ -91,7 +89,7 @@ class CinnCompiler {
std::unordered_map<CinnCacheKey, std::unique_ptr<CinnCompiledObject>,
CinnCacheKey::Hash>
cache_;
std::int64_t real_compiled_num_{0};
std::atomic_int64_t real_compiled_num_{0};
mutable RWLock rwlock_;

DISABLE_COPY_AND_ASSIGN(CinnCompiler);
Expand Down
3 changes: 2 additions & 1 deletion paddle/fluid/platform/flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,8 @@ PADDLE_DEFINE_EXPORTED_string(allow_cinn_ops, "",
* Name: FLAGS_deny_cinn_ops
* Since Version: 2.3
* Value Range: string, default=""
* Example: FLAGS_deny_cinn_ops="mul" would block `mul` op when using CINN
* Example: FLAGS_deny_cinn_ops="mul;relu" would block `mul` and `relu` two ops
* when using CINN
*/
PADDLE_DEFINE_EXPORTED_string(deny_cinn_ops, "",
"It controls the cinn op subset to be not used.");
Expand Down

0 comments on commit 6560f06

Please sign in to comment.