mirror of https://github.com/hpcaitech/ColossalAI
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.1 KiB
43 lines
1.1 KiB
10 months ago
|
import platform
|
||
7 months ago
|
from typing import List
|
||
10 months ago
|
|
||
7 months ago
|
from ...cpp_extension import _CppExtension
|
||
10 months ago
|
|
||
|
|
||
|
class CpuAdamArmExtension(_CppExtension):
|
||
|
def __init__(self):
|
||
|
super().__init__(name="cpu_adam_arm")
|
||
|
|
||
8 months ago
|
def is_available(self) -> bool:
|
||
10 months ago
|
# only arm allowed
|
||
|
return platform.machine() == "aarch64"
|
||
|
|
||
8 months ago
|
def assert_compatible(self) -> None:
|
||
10 months ago
|
arch = platform.machine()
|
||
|
assert (
|
||
|
arch == "aarch64"
|
||
|
), f"[extension] The {self.name} kernel requires the CPU architecture to be aarch64 but got {arch}"
|
||
|
|
||
|
# necessary 4 functions
|
||
|
def sources_files(self):
|
||
|
ret = [
|
||
7 months ago
|
self.csrc_abs_path("kernel/arm/cpu_adam_arm.cpp"),
|
||
10 months ago
|
]
|
||
|
return ret
|
||
|
|
||
7 months ago
|
def include_dirs(self) -> List[str]:
|
||
|
return super().include_dirs()
|
||
10 months ago
|
|
||
|
def cxx_flags(self):
|
||
|
extra_cxx_flags = [
|
||
|
"-std=c++14",
|
||
|
"-std=c++17",
|
||
|
"-g",
|
||
|
"-Wno-reorder",
|
||
|
"-fopenmp",
|
||
|
]
|
||
|
return ["-O3"] + self.version_dependent_macros + extra_cxx_flags
|
||
|
|
||
|
def nvcc_flags(self):
|
||
|
return []
|