/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck_tile/host/reference/reference_batched_masking.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck_tile/host/reference/reference_batched_masking.hpp Source File#

Composable Kernel: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck_tile/host/reference/reference_batched_masking.hpp Source File
reference_batched_masking.hpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: MIT
2 // Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
3 
4 #pragma once
5 
6 #include "ck_tile/core.hpp"
8 #include <thread>
9 
10 namespace ck_tile {
11 
12 template <typename CDataType, typename MaskingType>
13 CK_TILE_HOST void reference_batched_masking(HostTensor<CDataType>& c_b_m_n, const MaskingType& mask)
14 {
15  const int M = c_b_m_n.mDesc.get_lengths()[1];
16  const int N = c_b_m_n.mDesc.get_lengths()[2];
17 
18  auto f = [&](auto batch) {
19  for(int n = 0; n < N; ++n)
20  {
21  for(int m = 0; m < M; ++m)
22  {
23  if(mask.IsOutOfBound(m, n))
24  c_b_m_n(batch, m, n) = -ck_tile::numeric<CDataType>::infinity();
25  }
26  }
27  };
28 
30  c_b_m_n.mDesc.get_lengths()[0])(std::thread::hardware_concurrency());
31 }
32 } // namespace ck_tile
#define CK_TILE_HOST
Definition: config.hpp:40
Definition: cluster_descriptor.hpp:13
CK_TILE_HOST auto make_ParallelTensorFunctor(F f, Xs... xs)
Definition: host_tensor.hpp:329
CK_TILE_HOST void reference_batched_masking(HostTensor< CDataType > &c_b_m_n, const MaskingType &mask)
Definition: reference_batched_masking.hpp:13
const std::vector< std::size_t > & get_lengths() const
Definition: host_tensor.hpp:198
Definition: host_tensor.hpp:336
Descriptor mDesc
Definition: host_tensor.hpp:800
static constexpr CK_TILE_HOST_DEVICE T infinity()
Definition: numeric.hpp:38