/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 // Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
2 // SPDX-License-Identifier: MIT
3 
4 #pragma once
5 
6 #include <cstdlib>
7 #include <iostream>
8 #include <vector>
9 #include <iterator>
10 
12 
13 namespace ck {
14 
15 template <typename T>
16 std::ostream& operator<<(std::ostream& os, const std::vector<T>& v)
17 {
18  std::copy(std::begin(v), std::end(v), std::ostream_iterator<T>(os, " "));
19  return os;
20 }
21 
22 template <typename T, std::size_t N>
23 std::ostream& operator<<(std::ostream& os, const std::array<T, N>& v)
24 {
25  std::copy(std::begin(v), std::end(v), std::ostream_iterator<T>(os, " "));
26  return os;
27 }
28 
29 template <typename... Ts>
30 std::ostream& operator<<(std::ostream& os, const TensorDescriptor<Ts...>& desc)
31 {
32  constexpr index_t nDim = remove_cvref_t<decltype(desc)>::GetNumOfDimension();
33 
34  os << "{";
35 
36  static_for<0, nDim - 1, 1>{}([&](auto i) { os << desc.GetLength(i) << ", "; });
37 
38  os << desc.GetLength(Number<nDim - 1>{});
39 
40  os << "}";
41 
42  return os;
43 }
44 
45 } // namespace ck
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
Definition: ck.hpp:270
std::ostream & operator<<(std::ostream &os, const std::vector< T > &v)
Definition: io.hpp:16
remove_cv_t< remove_reference_t< T > > remove_cvref_t
Definition: type.hpp:297
int32_t index_t
Definition: ck.hpp:301
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