chromium/third_party/ruy/src/ruy/kernel.h

/* Copyright 2019 Google LLC. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef RUY_RUY_KERNEL_H_
#define RUY_RUY_KERNEL_H_

#include "ruy/kernel_common.h"
#include "ruy/mul_params.h"
#include "ruy/platform.h"
#include "ruy/trace.h"

// IWYU pragma: begin_exports
#if RUY_PLATFORM_NEON
#include "ruy/kernel_arm.h"
#elif RUY_PLATFORM_X86
#include "ruy/kernel_x86.h"
#endif
// IWYU pragma: end_exports

namespace ruy {

// KernelArgs is a helper to access the template parameter values from a Kernel
// template instantiation.
template <typename KernelType>
struct KernelArgs {};

KernelArgs<Kernel<tPath, tLhsScalar, tRhsScalar, tAccumScalar, tDstScalar>>;

// RunKernel::Run() is the only place that directly invokes Kernel::Run().
// It performs the types un-erasure, and factoring all Kernel::Run() calls
// through this function also gives a single place where to conditionally
// implement RUY_OPT(FAT_KERNEL). This should be a function but is a class to
// hide and share some boilerplate (see the member types, and the RunTyped
// method also using them).
template <typename KernelType>
class RunKernel final {};

template <Path ThePath>
struct StandardCppKernelLayout {};

template <>
struct StandardCppKernelLayout<Path::kStandardCpp> {};

// A variant exercising RowMajor square blocks
template <>
struct StandardCppKernelLayout<Path::kInternalStandardCppVariant1> {};

// A variant with a rectangular layout: 4x8
template <>
struct StandardCppKernelLayout<Path::kInternalStandardCppVariant2> {};

// A variant with different block orders in LHS vs RHS.
template <>
struct StandardCppKernelLayout<Path::kInternalStandardCppVariant3> {};

// General implementation of the Kernel template, overridden by template
// specializations for specific SIMD code paths. This general implementation
// covers Path::kStandardCpp and its internal test-only variants.
template <Path ThePath, typename LhsScalar, typename RhsScalar,
          typename AccumScalar, typename DstScalar>
struct Kernel {};

}  // namespace ruy

#endif  // RUY_RUY_KERNEL_H_