Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NeonBackend how to support multi thread parallel inference #798

Open
xiaotongnii opened this issue Jan 22, 2025 · 1 comment
Open

NeonBackend how to support multi thread parallel inference #798

xiaotongnii opened this issue Jan 22, 2025 · 1 comment

Comments

@xiaotongnii
Copy link

xiaotongnii commented Jan 22, 2025

NeonBackend how to support multi thread inference。
support multi thread parallel in Neon operator,like onnxruntime IntraOpNumThreads;
Or Others

NeonBackendModelContext::NeonBackendModelContext(const ModelOptions& modelOptions)
    : m_IsFastMathEnabled(false), m_NumberOfThreads(0)
{
   if (!modelOptions.empty())
   {
       ParseOptions(modelOptions, "CpuAcc", [&](std::string name, const BackendOptions::Var& value)
       {
           if (name == "FastMathEnabled")
           {
               m_IsFastMathEnabled |= ParseBool(value, false);
           }
           if (name == "NumberOfThreads")
           {
               m_NumberOfThreads |= ParseUnsignedInt(value, 0);
           }
       });
   }
}

bool NeonBackendModelContext::IsFastMathEnabled() const
{
    return m_IsFastMathEnabled;
}

unsigned int NeonBackendModelContext::GetNumberOfThreads() const
{
    return m_NumberOfThreads;
}

@orlmon01
Copy link
Collaborator

orlmon01 commented Feb 5, 2025

Hiya Xiaotongnii,
Yes, if you want to do multithread inference you can set it in the NeonBackendModelContext by changing the number of threads from the default 0 to whatever you want it to use. This will be passed down into the Neon backend and used wherever possible to multithread the ops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants