ronantakizawa/codereview-bench huggingface dataset:
Repository: microsoft/onnxruntime
File: onnxruntime/core/common/spin_pause.cc (C++)

Code before:
#include <x86intrin.h>
#include <immintrin.h>
#include <cstdlib>
#endif
#endif

namespace onnxruntime {

#if defined(_M_AMD64) || defined(__x86_64__)
static const bool tpause = CPUIDInfo::GetCPUIDInfo().HasTPAUSE();
static const std::uint64_t spin_delay_cycles = 1000;
#endif

namespace concurrency {

// Intrinsic to use in spin-loops
void SpinPause() {
#if defined(_M_AMD64) || defined(__x86_64__)
#if defined(_WIN32)
  if (tpause) {
    _tpause(0x0, __rdtsc() + spin_delay_cycles);
  } else {
    _mm_pause();
  }
#elif defined(__linux__)
  if (__builtin_cpu_supports("waitpkg")) {
    __builtin_ia32_tpause(0x0, __rdtsc() + spin_delay_cycles);
  } else {
    _mm_pause();
  }
#else
  _mm_pause();
#endif
#endif
}

}  // namespace concurrency
}  // namespace onnxruntime


Review comment (refactor):
is it possible to move this into the logic that sets `CPUIDInfo::has_tpause_` so we can just check `tpause` here?

Code after:
#include <x86intrin.h>
#include <immintrin.h>
#endif
#endif

namespace onnxruntime {
namespace concurrency {

// Intrinsic to use in spin-loops
void SpinPause() {
#if (defined(_M_AMD64) || defined(__x86_64__)) && \
    !defined(__ANDROID__) &&                      \
    !defined(__APPLE__)

  static const bool has_tpause = CPUIDInfo::GetCPUIDInfo().HasTPAUSE();
  static constexpr uint64_t tpause_spin_delay_cycles = 1000;
  if (has_tpause) {
#if defined(_WIN32)
    _tpause(0x0, __rdtsc() + tpause_spin_delay_cycles);
#elif defined(__linux__)
    __builtin_ia32_tpause(0x0, __rdtsc() + tpause_spin_delay_cycles);
#else
    _mm_pause();
#endif
  } else {
    _mm_pause();
  }
#endif
}

}  // namespace concurrency
}  // namespace onnxruntime
Repository: microsoft/onnxruntime
File: onnxruntime/core/common/spin_pause.cc (C++)

Code before:
// Licensed under the MIT License.

#include "core/common/spin_pause.h"

#if defined(_M_AMD64)
#include <intrin.h>
#endif

#if defined(__x86_64__)
#include <xmmintrin.h>
#endif

#if defined(_M_AMD64) || defined(__x86_64__)
#include "core/common/cpuid_info.h"
#if defined(__linux__)
#include <x86intrin.h>
#include <immintrin.h>
#include <cstdlib>
#endif
#endif

namespace onnxruntime {

#if defined(_M_AMD64) || defined(__x86_64__)
static const bool tpause = CPUIDInfo::GetCPUIDInfo().HasTPAUSE();
static const std::uint64_t spin_delay_cycles = 1000;
#endif

namespace concurrency {

// Intrinsic to use in spin-loops
void SpinPause() {
#if defined(_M_AMD64) || defined(__x86_64__)
#if defined(_WIN32)
  if (tpause) {
    _tpause(0x0, __rdtsc() + spin_delay_cycles);
  } else {
    _mm_pause();
  }
#elif defined(__linux__)
  if (__builtin_cpu_supports("waitpkg")) {
    __builtin_ia32_tpause(0x0, __rdtsc() + spin_delay_cycles);
  } else {
    _mm_pause();
  }
#else
  _mm_pause();
#endif
#endif
}


Review comment (suggestion):
also some naming and declaration suggestions
```suggestion
static const bool has_tpause = CPUIDInfo::GetCPUIDInfo().HasTPAUSE();
static constexpr uint64_t tpause_spin_delay_cycles = 1000;
```

Code after:
// Licensed under the MIT License.

#include "core/common/spin_pause.h"

#if defined(_M_AMD64)
#include <intrin.h>
#endif

#if defined(__x86_64__)
#include <xmmintrin.h>
#endif

#if defined(_M_AMD64) || defined(__x86_64__)
#include "core/common/cpuid_info.h"
#if defined(__linux__)
#include <x86intrin.h>
#include <immintrin.h>
#endif
#endif

namespace onnxruntime {
namespace concurrency {

// Intrinsic to use in spin-loops
void SpinPause() {
#if (defined(_M_AMD64) || defined(__x86_64__)) && \
    !defined(__ANDROID__) &&                      \
    !defined(__APPLE__)

  static const bool has_tpause = CPUIDInfo::GetCPUIDInfo().HasTPAUSE();
  static constexpr uint64_t tpause_spin_delay_cycles = 1000;
  if (has_tpause) {
#if defined(_WIN32)
    _tpause(0x0, __rdtsc() + tpause_spin_delay_cycles);
#elif defined(__linux__)
    __builtin_ia32_tpause(0x0, __rdtsc() + tpause_spin_delay_cycles);
#else
    _mm_pause();
#endif
  } else {
    _mm_pause();
  }
#endif
}

}  // namespace concurrency
}  // namespace onnxruntime
Repository: microsoft/onnxruntime
File: onnxruntime/core/common/spin_pause.cc (C++)

Code before:
#include "core/common/spin_pause.h"

#if defined(_M_AMD64)
#include <intrin.h>
#endif

#if defined(__x86_64__)
#include <xmmintrin.h>
#endif

#if defined(_M_AMD64) || defined(__x86_64__)
#include "core/common/cpuid_info.h"
#if defined(__linux__)
#include <x86intrin.h>
#include <immintrin.h>
#endif
#endif

namespace onnxruntime {
namespace concurrency {

// Intrinsic to use in spin-loops
void SpinPause() {
#if defined(_M_AMD64) || defined(__x86_64__)
  static const bool has_tpause = CPUIDInfo::GetCPUIDInfo().HasTPAUSE();
  static constexpr std::uint64_t tpause_spin_delay_cycles = 1000;
  if (has_tpause) {
#if defined(_WIN32)
  _tpause(0x0, __rdtsc() + tpause_spin_delay_cycles);
#elif defined(__linux__) && !defined(__aarch64__)
  __builtin_ia32_tpause(0x0, __rdtsc() + tpause_spin_delay_cycles);
#else
    _mm_pause();
#endif
  } else {
    _mm_pause();
  }

#else
  _mm_pause();
#endif
}

}  // namespace concurrency
}  // namespace onnxruntime


Review comment (suggestion):
nit
```suggestion
  static constexpr uint64_t tpause_spin_delay_cycles = 1000;
```

Code after:
#include "core/common/spin_pause.h"

#if defined(_M_AMD64)
#include <intrin.h>
#endif

#if defined(__x86_64__)
#include <xmmintrin.h>
#endif

#if defined(_M_AMD64) || defined(__x86_64__)
#include "core/common/cpuid_info.h"
#if defined(__linux__)
#include <x86intrin.h>
#include <immintrin.h>
#endif
#endif

namespace onnxruntime {
namespace concurrency {

// Intrinsic to use in spin-loops
void SpinPause() {
#if (defined(_M_AMD64) || defined(__x86_64__)) && \
    !defined(__ANDROID__) &&                      \
    !defined(__APPLE__)

  static const bool has_tpause = CPUIDInfo::GetCPUIDInfo().HasTPAUSE();
  static constexpr uint64_t tpause_spin_delay_cycles = 1000;
  if (has_tpause) {
#if defined(_WIN32)
    _tpause(0x0, __rdtsc() + tpause_spin_delay_cycles);
#elif defined(__linux__)
    __builtin_ia32_tpause(0x0, __rdtsc() + tpause_spin_delay_cycles);
#else
    _mm_pause();
#endif
  } else {
    _mm_pause();
  }
#endif
}

}  // namespace concurrency
}  // namespace onnxruntime
Repository: microsoft/onnxruntime
File: onnxruntime/core/common/spin_pause.cc (C++)

Code before:
#endif

#if defined(__x86_64__)
#include <xmmintrin.h>
#endif

#if defined(_M_AMD64) || defined(__x86_64__)
#include "core/common/cpuid_info.h"
#if defined(__linux__)
#include <x86intrin.h>
#include <immintrin.h>
#endif
#endif

namespace onnxruntime {
namespace concurrency {

// Intrinsic to use in spin-loops
void SpinPause() {
#if defined(_M_AMD64) || defined(__x86_64__)
  static const bool has_tpause = CPUIDInfo::GetCPUIDInfo().HasTPAUSE();
  static constexpr std::uint64_t tpause_spin_delay_cycles = 1000;
  if (has_tpause) {
#if defined(_WIN32)
  _tpause(0x0, __rdtsc() + tpause_spin_delay_cycles);
#elif defined(__linux__) && !defined(__aarch64__)
  __builtin_ia32_tpause(0x0, __rdtsc() + tpause_spin_delay_cycles);
#else
    _mm_pause();
#endif
  } else {
    _mm_pause();
  }

#else
  _mm_pause();
#endif
}

}  // namespace concurrency
}  // namespace onnxruntime


Review comment (suggestion):
is `defined(__aarch64__)` possible here? we're already within `defined(_M_AMD64) || defined(__x86_64__)`

Code after:
#endif

#if defined(__x86_64__)
#include <xmmintrin.h>
#endif

#if defined(_M_AMD64) || defined(__x86_64__)
#include "core/common/cpuid_info.h"
#if defined(__linux__)
#include <x86intrin.h>
#include <immintrin.h>
#endif
#endif

namespace onnxruntime {
namespace concurrency {

// Intrinsic to use in spin-loops
void SpinPause() {
#if (defined(_M_AMD64) || defined(__x86_64__)) && \
    !defined(__ANDROID__) &&                      \
    !defined(__APPLE__)

  static const bool has_tpause = CPUIDInfo::GetCPUIDInfo().HasTPAUSE();
  static constexpr uint64_t tpause_spin_delay_cycles = 1000;
  if (has_tpause) {
#if defined(_WIN32)
    _tpause(0x0, __rdtsc() + tpause_spin_delay_cycles);
#elif defined(__linux__)
    __builtin_ia32_tpause(0x0, __rdtsc() + tpause_spin_delay_cycles);
#else
    _mm_pause();
#endif
  } else {
    _mm_pause();
  }
#endif
}

}  // namespace concurrency
}  // namespace onnxruntime
Repository: microsoft/onnxruntime
File: onnxruntime/core/platform/check_intel.cc (C++)

Code before:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#include "check_intel.h"

#if (defined(_M_AMD64) || defined(__x86_64__))
#if defined(__linux__)
#include <cpuid.h>
#elif defined(_WIN32)
#include <intrin.h>
#endif
#endif

namespace onnxruntime {

CheckIntelResult CheckIntel() {
  CheckIntelResult intel_check = {false, false};
  bool is_intel = false;
  bool is_intel_specified_platform = false;

#if (defined(_M_AMD64) || defined(__x86_64__))
#if defined(_WIN32)
  constexpr unsigned int kVendorID_Intel[] = {0x756e6547, 0x6c65746e, 0x49656e69};  // "GenuntelineI"
  constexpr unsigned int kVendorID_IntelSpecifiedPlatformIDs[] = {
      // ExtendedModel, ExtendedFamily, Family Code, and Model Number
      0xa06a,  // MTL
      0xc065,  // ARL-H
      0xb065   // ARL-U
  };

Review comment (suggestion):
```suggestion
#include "core/platform/check_intel.h"
```

Code after:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#include "core/platform/check_intel.h"

#if (defined(_M_AMD64) || defined(__x86_64__))
#if defined(__linux__)
#include <cpuid.h>
#elif defined(_WIN32)
#include <intrin.h>
#endif
#endif

namespace onnxruntime {

CheckIntelResult CheckIntel() {
  CheckIntelResult intel_check = {false, false};
  bool is_intel = false;
  bool is_intel_specified_platform = false;

#if (defined(_M_AMD64) || defined(__x86_64__))
#if defined(_WIN32)
  constexpr unsigned int kVendorID_Intel[] = {0x756e6547, 0x6c65746e, 0x49656e69};  // "GenuntelineI"
  constexpr unsigned int kVendorID_IntelSpecifiedPlatformIDs[] = {
      // ExtendedModel, ExtendedFamily, Family Code, and Model Number
      0xa06a,  // MTL
      0xc065,  // ARL-H
      0xb065   // ARL-U
  };
Repository: microsoft/onnxruntime
File: onnxruntime/core/platform/check_intel.cc (C++)

Code before:
  __get_cpuid(1, &regs[0], &regs[1], &regs[2], &regs[3]);

  unsigned int base_family = (regs[0] >> 8) & 0xF;
  unsigned int base_model = (regs[0] >> 4) & 0xF;
  unsigned int extended_model = (regs[0] >> 16) & 0xF;

  unsigned int model =
      (base_family == 0x6 || base_family == 0xF)
          ? (base_model + (extended_model << 4))
          : base_model;

  constexpr unsigned int kVendorID_IntelSpecifiedPlatformIDs[] = {
      // ExtendedModel, ExtendedFamily, Family Code, and Model Number
      170,  // MTL (0xAA)
      197,  // ARL-H (0xC5)
      198   // ARL-U (0xC6)
  };

  for (auto id : kVendorID_IntelSpecifiedPlatformIDs) {
    if (model == id) {
      is_intel_specified_platform = true;
      break;
    }
  }
#endif  //__linux__
#endif //(_M_AMD64) || (__x86_64__)

  intel_check.is_intel = is_intel;
  intel_check.is_intel_specified_platform = is_intel_specified_platform;

  return intel_check;
}

}  // namespace onnxruntime


Review comment (suggestion):
I think this should make the formatting check happy. if not, try running `clang-format -i` on this file.
```suggestion
#endif  // (_M_AMD64) || (__x86_64__)
```

Code after:

  __get_cpuid(1, &regs[0], &regs[1], &regs[2], &regs[3]);

  unsigned int base_family = (regs[0] >> 8) & 0xF;
  unsigned int base_model = (regs[0] >> 4) & 0xF;
  unsigned int extended_model = (regs[0] >> 16) & 0xF;

  unsigned int model =
      (base_family == 0x6 || base_family == 0xF)
          ? (base_model + (extended_model << 4))
          : base_model;

  constexpr unsigned int kVendorID_IntelSpecifiedPlatformIDs[] = {
      // ExtendedModel, ExtendedFamily, Family Code, and Model Number
      170,  // MTL (0xAA)
      197,  // ARL-H (0xC5)
      198   // ARL-U (0xC6)
  };

  for (auto id : kVendorID_IntelSpecifiedPlatformIDs) {
    if (model == id) {
      is_intel_specified_platform = true;
      break;
    }
  }
#endif  //__linux__
#endif  // (_M_AMD64) || (__x86_64__)

  intel_check.is_intel = is_intel;
  intel_check.is_intel_specified_platform = is_intel_specified_platform;

  return intel_check;
}

}  // namespace onnxruntime
Repository: microsoft/onnxruntime
File: onnxruntime/core/providers/cpu/nn/layer_norm_impl.cc (C++)

Code before:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#include "layer_norm_impl.h"
#include "layer_norm_helper.h"

#include "core/common/safeint.h"
#include "core/framework/tensor.h"
#include "core/mlas/inc/mlas.h"
#include "core/platform/threadpool.h"
#include "core/providers/common.h"
#include "core/util/force_inline.h"
#include "core/util/math_cpuonly.h"
#include <Eigen/Core>

namespace onnxruntime {

namespace {

template <typename T,
          typename U,
          typename = std::enable_if_t<std::is_same_v<T, float> || std::is_same_v<T, double>, void>>
void ComputeJob(
    const T* X_data,
    const T* scale_data,
    const T* bias_data,
    const ptrdiff_t task_idx,
    const int64_t norm_size,
    const int64_t broadcast_param,
    const float* scale_float_ptr,
    const float* bias_float_ptr,
    float epsilon,
    bool simplified,
    T* Y_data,
    U* mean_data,
    U* inv_std_dev_data,
    AllocatorPtr alloc) {
  ORT_UNUSED_PARAMETER(scale_float_ptr);  // only used in MLFloat16 overload
  ORT_UNUSED_PARAMETER(bias_float_ptr);   // only used in MLFloat16 overload

Review comment (refactor):
`<Eigen/Core>` is already included in `core/util/math_cpuonly.h`. there, it also has some handling for warnings. I'd suggest just using that so we don't need to duplicate the warning suppressions here too.

Code after:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#include "layer_norm_impl.h"
#include "layer_norm_helper.h"

#include "core/common/safeint.h"
#include "core/framework/tensor.h"
#include "core/mlas/inc/mlas.h"
#include "core/platform/threadpool.h"
#include "core/providers/common.h"
#include "core/util/force_inline.h"
#include "core/util/math_cpuonly.h"

namespace onnxruntime {

namespace {

template <typename T,
          typename U,
          typename = std::enable_if_t<std::is_same_v<T, float> || std::is_same_v<T, double>, void>>
void ComputeJob(
    const T* X_data,
    const T* scale_data,
    const T* bias_data,
    const ptrdiff_t task_idx,
    const int64_t norm_size,
    const int64_t broadcast_param,
    const float* scale_float_ptr,
    const float* bias_float_ptr,
    float epsilon,
    bool simplified,
    T* Y_data,
    U* mean_data,
    U* inv_std_dev_data,
    AllocatorPtr alloc) {
  ORT_UNUSED_PARAMETER(scale_float_ptr);  // only used in MLFloat16 overload
  ORT_UNUSED_PARAMETER(bias_float_ptr);   // only used in MLFloat16 overload
  ORT_UNUSED_PARAMETER(alloc);
Repository: microsoft/onnxruntime
File: onnxruntime/test/contrib_ops/matmul_2bits_test.cc (C++)

Code before:
    TypedTestParams<4, 32, 32, 16>,
    TypedTestParams<4, 32, 16, 128>,
    TypedTestParams<4, 288, 16, 16>>;

template <typename T>
class MatMulNBits : public ::testing::Test {
 public:
  static constexpr int batch_size = T::batch_size;
  static constexpr int M = T::M;
  static constexpr int N = T::N;
  static constexpr int K = T::K;
};

TYPED_TEST_SUITE(MatMulNBits, TestTypes);

TYPED_TEST(MatMulNBits, Float32_2Bits_Accuracy0) {
  TestMatMul2BitsTyped<float, TestFixture::batch_size, TestFixture::M, TestFixture::N, TestFixture::K, 0>();
}

TYPED_TEST(MatMulNBits, Float32_2Bits_Accuracy4) {
  TestMatMul2BitsTyped<float, TestFixture::batch_size, TestFixture::M, TestFixture::N, TestFixture::K, 4>();
}

}  // namespace test
}  // namespace onnxruntime

#endif  // ORT_MINIMAL_BUILD


Review comment (suggestion):
Sorry, forgot one thing. You should add webgpu ep to the execution_providers in L198 like https://github.com/microsoft/onnxruntime/blob/main/onnxruntime/test/contrib_ops/matmul_4bits_test.cc#L540-L543 did. Otherwise, these tests are not tested on webgpu ep. In this file, it also tests the zero points in L225 and L239. You can use them to test the zero points path or skip those tests for webgpu.

Code after:
    TypedTestParams<4, 1, 16, 16>,
    TypedTestParams<4, 2, 16, 16>,
    TypedTestParams<4, 32, 16, 16>,
    TypedTestParams<4, 32, 32, 16>,
    TypedTestParams<4, 32, 16, 128>,
    TypedTestParams<4, 288, 16, 16>>;

template <typename T>
class MatMulNBits : public ::testing::Test {
 public:
  static constexpr int batch_size = T::batch_size;
  static constexpr int M = T::M;
  static constexpr int N = T::N;
  static constexpr int K = T::K;
};

TYPED_TEST_SUITE(MatMulNBits, TestTypes);

TYPED_TEST(MatMulNBits, Float32_2Bits_Accuracy0) {
  TestMatMul2BitsTyped<float, TestFixture::batch_size, TestFixture::M, TestFixture::N, TestFixture::K, 0>();
}

TYPED_TEST(MatMulNBits, Float32_2Bits_Accuracy4) {
  TestMatMul2BitsTyped<float, TestFixture::batch_size, TestFixture::M, TestFixture::N, TestFixture::K, 4>();
}

}  // namespace test
}  // namespace onnxruntime

#endif  // ORT_MINIMAL_BUILD
Repository: microsoft/onnxruntime
File: onnxruntime/core/optimizer/transformer_memcpy.h (C/C++)

Code before:

#pragma once

#include <functional>

#include "gsl/gsl"

#include "core/common/common.h"
#include "core/common/inlined_containers.h"
#include "core/framework/execution_provider.h"
#include "core/framework/op_kernel.h"
#include "core/framework/kernel_registry_manager.h"
#include "core/optimizer/graph_transformer.h"

namespace onnxruntime {

/**
@Class MemcpyTransformer

Transformer that inserts nodes to copy memory between devices when needed.
*/
class MemcpyTransformer : public GraphTransformer {
 public:
  MemcpyTransformer(InlinedVector<gsl::not_null<const IExecutionProvider*>> providers,
                    const KernelRegistryManager& registry_manager)
      : GraphTransformer("MemcpyTransformer"),
        providers_(std::move(providers)),
        registry_manager_(std::cref(registry_manager)) {
  }

 private:
  Status ApplyImpl(Graph& graph, bool& modified, int graph_level, const logging::Logger& logger) const override;

  const InlinedVector<gsl::not_null<const IExecutionProvider*>> providers_;
  std::reference_wrapper<const KernelRegistryManager> registry_manager_;
};

}  // namespace onnxruntime


Review comment (suggestion):
You probably already saw this but there's a test that is still using the old `MemcpyTransformer()` constructor:

> test/framework/memcpy_transformer_test.cc:115:93: error: no matching function for call to ‘onnxruntime::MemcpyTransformer::MemcpyTransformer(<brace-enclosed initializer list>, onnxruntime::KernelRegistryManager&)’
  115 |   MemcpyTransformer transformer({onnxruntime::kCudaExecutionProvider}, test_registry_manager);

Code after:

#pragma once

#include <functional>

#include "gsl/gsl"

#include "core/common/common.h"
#include "core/common/inlined_containers.h"
#include "core/framework/execution_provider.h"
#include "core/framework/op_kernel.h"
#include "core/framework/kernel_registry_manager.h"
#include "core/optimizer/graph_transformer.h"

namespace onnxruntime {

using ProviderTypeToProviderMap = InlinedHashMap<std::string_view, gsl::not_null<const IExecutionProvider*>>;

/**
@Class MemcpyTransformer

Transformer that inserts nodes to copy memory between devices when needed.
*/
class MemcpyTransformer : public GraphTransformer {
 public:
  MemcpyTransformer(InlinedVector<gsl::not_null<const IExecutionProvider*>> providers,
                    const KernelRegistryManager& registry_manager);

 private:
  Status ApplyImpl(Graph& graph, bool& modified, int graph_level, const logging::Logger& logger) const override;

  const InlinedVector<gsl::not_null<const IExecutionProvider*>> providers_;
  const ProviderTypeToProviderMap providers_by_type_;
  std::reference_wrapper<const KernelRegistryManager> registry_manager_;
};

}  // namespace onnxruntime
Repository: microsoft/onnxruntime
File: onnxruntime/contrib_ops/cpu/quantization/dynamic_quantize_matmul.cc (C++)

Code before:

      bool share_prepacked_weights = (prepacked_weights != nullptr);
      if (share_prepacked_weights) {
        prepacked_weights->buffers_.push_back(std::move(packed_b_));
        prepacked_weights->buffer_sizes_.push_back(packed_b_size);
      }

      is_packed = true;
    }
    return Status::OK();
  }
#endif

  enum InputTensors : int {
    IN_A = 0,
    IN_B = 1,
    IN_B_SCALE = 2,
    IN_B_ZERO_POINT = 3,
    IN_BIAS = 4
  };

 protected:
  int GetBIdx() const override { return IN_B; }

 private:
  //Indicates when dynamic quantization is available so we can use the KleidiAI dynamic qgemm kernel
  bool can_use_dynamic_quant_mlas_{false};
#if defined(USE_KLEIDIAI) && !defined(_MSC_VER)
  //Indicates that the biases are a constant input and thus already quantized / packed
  bool dynamic_quant_mlas_bias_data_was_packed_{false};
#endif
};

class MatMulIntegerToFloat final : public MatMulIntegerToFloatBase {
 public:
  MatMulIntegerToFloat(const OpKernelInfo& info) : MatMulIntegerToFloatBase(info) {}

  Status Compute(OpKernelContext* context) const override;

  enum InputTensors : int {
    IN_A = 0,
    IN_B = 1,
    IN_A_SCALE = 2,
    IN_B_SCALE = 3,
    IN_A_ZERO_POINT = 4,
    IN_B_ZERO_POINT = 5,
    IN_BIAS = 6
  };

 protected:
  int GetBIdx() const override { return IN_B; }

Review comment (performance):
nit: would prefer to keep mention of KleidiAI within the USE_KLEIDIAI ifdefs if possible.

```suggestion
  // Indicates when MlasDynamicQGemmBatch() can be used
```

Code after:
      MlasDynamicQgemmPackB(N, K, reinterpret_cast<const int8_t*>(b_data), scales.data(), biases.data(),
                            packed_b_.get());

      bool share_prepacked_weights = (prepacked_weights != nullptr);
      if (share_prepacked_weights) {
        prepacked_weights->buffers_.push_back(std::move(packed_b_));
        prepacked_weights->buffer_sizes_.push_back(packed_b_size);
      }

      is_packed = true;
    }
    return Status::OK();
  }
#endif

  enum InputTensors : int {
    IN_A = 0,
    IN_B = 1,
    IN_B_SCALE = 2,
    IN_B_ZERO_POINT = 3,
    IN_BIAS = 4
  };

 protected:
  int GetBIdx() const override { return IN_B; }

 private:
  // Indicates when MlasDynamicQGemmBatch() can be used
  bool can_use_dynamic_quant_mlas_{false};
#if defined(USE_KLEIDIAI) && !defined(_MSC_VER)
  // Indicates that the biases are a constant input and thus already quantized / packed
  bool dynamic_quant_mlas_bias_data_was_packed_{false};
#endif
};

class MatMulIntegerToFloat final : public MatMulIntegerToFloatBase {
 public:
  MatMulIntegerToFloat(const OpKernelInfo& info) : MatMulIntegerToFloatBase(info) {}

  Status Compute(OpKernelContext* context) const override;

  enum InputTensors : int {
    IN_A = 0,
    IN_B = 1,
    IN_A_SCALE = 2,
    IN_B_SCALE = 3,
    IN_A_ZERO_POINT = 4,
    IN_B_ZERO_POINT = 5,
    IN_BIAS = 6
  };