Skip to content

KleidiAI library usage needs to check for SME2, not SME #26377

@john-dance

Description

@john-dance

Describe the issue

Commit cd450d1 introduced the usage of the KleidiAI library. However, the test to enable it in platform.cpp just checks for SME, rather than SME2.

    if(MLAS_CPUIDINFO::GetCPUIDInfo().HasArm_SME()){
        this->MlasGemmBatchOverride = ArmKleidiAI::MlasGemmBatch;
        this->MlasGemmPackBSizeOverride = ArmKleidiAI::MlasGemmPackBSize;
        this->MlasGemmPackBOverride = ArmKleidiAI::MlasGemmPackB;
        this->MlasConvPrepareOverride = ArmKleidiAI::MlasConvPrepare;
        this->MlasConvOverride = ArmKleidiAI::MlasConv;
    }

This allows the library to be used on systems that support SME but not SME2, leading to illegal instructions during a run.

The newest pytorch/cpuinfo implementation has support for cpuinfo_has_arm_sme2(). https://github.com/search?q=repo%3Apytorch%2Fcpuinfo%20cpuinfo_has_arm_sme2&type=code

This needs to be added to cpuid_info.cc and exposed with a new function. Meanwhile, the default build should include "--no_kleidiai".

To reproduce

Run a simple convolution using the CPU execution provider on a device that supports SME1, but not SME2.

Urgency

No response

Platform

Android

OS Version

16

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

1.23

ONNX Runtime API

C++

Architecture

ARM64

Execution Provider

Default CPU

Execution Provider Library Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform:mobileissues related to ONNX Runtime mobile; typically submitted using template

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions