mirror of https://github.com/hpcaitech/ColossalAI
fix bugs in CPU adam (#633)
* add cpu adam counter for all cpu adam * fixed updating error in adam kernelpull/657/head
parent
1e2557e801
commit
b31daed4cf
@ -0,0 +1,14 @@
|
||||
class CpuAdamCounter(object):
|
||||
"""Used to record the total number of CPU Adam.
|
||||
We must use it to avoid hybrid cpu adam and cpu adam using the same id.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.number = 0
|
||||
|
||||
def __call__(self):
|
||||
self.number += 1
|
||||
return self.number - 1
|
||||
|
||||
|
||||
CPU_ADAM_CNT = CpuAdamCounter()
|
Loading…
Reference in new issue