io.hpp Source File

io.hpp Source File#

Composable Kernel: 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
13template <typename T>
14std::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
20template <typename T, std::size_t N>
21std::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
27template <typename... Ts>
28std::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
int32_t index_t
Definition ck.hpp:299
remove_cv_t< remove_reference_t< T > > remove_cvref_t
Definition type.hpp:297
integral_constant< index_t, N > Number
Definition number.hpp:12
Definition tensor_description/tensor_descriptor.hpp:28
__host__ __device__ constexpr auto GetLength(Number< IDim >) const
Definition tensor_description/tensor_descriptor.hpp:147
Definition functional2.hpp:33