[Bugfix][CPU] Make the Apple Silicon BF16 probe fall back instead of raising (#51627)
Signed-off-by: Kush Zingade <kush.zingade@gmail.com>
This commit is contained in:
@@ -54,12 +54,15 @@ class CpuPlatform(Platform):
|
|||||||
elif self.get_cpu_architecture() == CpuArchEnum.ARM and sys.platform.startswith(
|
elif self.get_cpu_architecture() == CpuArchEnum.ARM and sys.platform.startswith(
|
||||||
"darwin"
|
"darwin"
|
||||||
):
|
):
|
||||||
if (
|
# sysctl exits non-zero when the OID is absent, so check_output would
|
||||||
subprocess.check_output(
|
# raise instead of letting the fp16/fp32 fallback below run.
|
||||||
["sysctl -n hw.optional.arm.FEAT_BF16"], shell=True
|
bf16 = (
|
||||||
).strip()
|
subprocess.run(
|
||||||
|
["sysctl", "-n", "hw.optional.arm.FEAT_BF16"], capture_output=True
|
||||||
|
).stdout.strip()
|
||||||
== b"1"
|
== b"1"
|
||||||
):
|
)
|
||||||
|
if bf16:
|
||||||
return [torch.bfloat16, torch.float16, torch.float32]
|
return [torch.bfloat16, torch.float16, torch.float32]
|
||||||
return [torch.float16, torch.float32]
|
return [torch.float16, torch.float32]
|
||||||
elif self.get_cpu_architecture() == CpuArchEnum.RISCV:
|
elif self.get_cpu_architecture() == CpuArchEnum.RISCV:
|
||||||
|
|||||||
Reference in New Issue
Block a user