未验证 提交 04285ab4 编写于 作者: L Leo Chen 提交者: GitHub

[AMP] support setting amp_level in multi-thread (#39198)

上级 3e80253a
...@@ -32,6 +32,8 @@ namespace imperative { ...@@ -32,6 +32,8 @@ namespace imperative {
thread_local bool Tracer::has_grad_ = true; thread_local bool Tracer::has_grad_ = true;
thread_local AmpLevel Tracer::amp_level_ = AmpLevel::O0;
static std::shared_ptr<Tracer> g_current_tracer(nullptr); static std::shared_ptr<Tracer> g_current_tracer(nullptr);
const std::shared_ptr<Tracer>& GetCurrentTracer() { return g_current_tracer; } const std::shared_ptr<Tracer>& GetCurrentTracer() { return g_current_tracer; }
......
...@@ -126,7 +126,7 @@ class Tracer { ...@@ -126,7 +126,7 @@ class Tracer {
platform::Place expected_place_; platform::Place expected_place_;
GarbageCollectorMap gcs_; GarbageCollectorMap gcs_;
static thread_local bool has_grad_; static thread_local bool has_grad_;
AmpLevel amp_level_{AmpLevel::O0}; static thread_local AmpLevel amp_level_;
}; };
// To access static variable current_tracer // To access static variable current_tracer
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册