/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/host_utility/io.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/host_utility/io.hpp Source File#

Composable Kernel: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/host_utility/io.hpp Source File
io.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 <cstdlib>
7 #include <iostream>
8 #include <vector>
9 #include <iterator>
10 
12 
13 template <typename T>
14 std::ostream& operator<<(std::ostream& os, const std::vector<T>& v)
15 {
16  std::copy(std::begin(v), std::end(v), std::ostream_iterator<T>(os, " "));
17  return os;
18 }
19 
20 template <typename T, std::size_t N>
21 std::ostream& operator<<(std::ostream& os, const std::array<T, N>& v)
22 {
23  std::copy(std::begin(v), std::end(v), std::ostream_iterator<T>(os, " "));
24  return os;
25 }
26 
27 template <typename... Ts>
28 std::ostream& operator<<(std::ostream& os, const ck::TensorDescriptor<Ts...>& desc)
29 {
30  constexpr ck::index_t nDim = ck::remove_cvref_t<decltype(desc)>::GetNumOfDimension();
31 
32  os << "{";
33 
34  ck::static_for<0, nDim - 1, 1>{}([&](auto i) { os << desc.GetLength(i) << ", "; });
35 
36  os << desc.GetLength(ck::Number<nDim - 1>{});
37 
38  os << "}";
39 
40  return os;
41 }
std::ostream & operator<<(std::ostream &os, const std::vector< T > &v)
Definition: io.hpp:14
auto copy(InputRange &&range, OutputIterator iter) -> decltype(std::copy(std::begin(std::forward< InputRange >(range)), std::end(std::forward< InputRange >(range)), iter))
Definition: algorithm.hpp:14
remove_cv_t< remove_reference_t< T > > remove_cvref_t
Definition: type.hpp:297
int32_t index_t
Definition: ck.hpp:298
Definition: tensor_descriptor.hpp:28
__host__ constexpr __device__ auto GetLength(Number< IDim >) const
Definition: tensor_descriptor.hpp:147
Definition: integral_constant.hpp:20
Definition: functional2.hpp:33