docs/core__io_8h_source.html
| | CUTLASS
CUDA Templates for Linear Algebra Subroutines and Solvers |
core_io.h
Go to the documentation of this file.
1 /***************************************************************************************************
2 * Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are permitted
5 * provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright notice, this list of
7 * conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright notice, this list of
9 * conditions and the following disclaimer in the documentation and/or other materials
10 * provided with the distribution.
11 * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12 * to endorse or promote products derived from this software without specific prior written
13 * permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21 * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 **************************************************************************************************/
29 #pragma once
30
31 #include <iostream>
32 #include <typeinfo>
33
34 #include "cutlass/coord.h"
35 #include "cutlass/numeric_types.h"
36
37 namespace cutlass {
38
40
41 template <int Rank>
42 inline
43 std::ostream& operator<<(std::ostream& out, Coord<Rank> const& coord) {
44for (int i = 0; i < Rank; ++i) {
45 out << (i ? ", " : "") << coord[i];
46 }
47return out;
48 }
49
51
52 inline
53 std::istream & operator>>(std::istream &stream, half_t &x) {
54float tmp;
55 stream >> tmp;
56 x = static_cast<cutlass::half_t>(tmp);
57return stream;
58 }
59
60 inline
61 std::ostream & operator<<(std::ostream &out, half_t const &x) {
62return out << float(x);
63 }
64
66
68 template <typename T>
70
73
76
78ScalarIO(T value): value(value) {}
79 };
80
82
84 template <typename T>
85 inline std::ostream &operator<<(std::ostream &out, ScalarIO<T> const &scalar) {
86return out << scalar.value;
87 }
88
90 template <>
91 inline std::ostream &operator<<(std::ostream &out, ScalarIO<int8_t> const &scalar) {
92return out << int(scalar.value);
93 }
94
96 template <>
97 inline std::ostream &operator<<(std::ostream &out, ScalarIO<uint8_t> const &scalar) {
98return out << unsigned(scalar.value);
99 }
100
102
103 } // namespace cutlass
104
Definition: aligned_buffer.h:35
A Coord is a coordinate of arbitrary rank into a tensor or matrix.
IEEE half-precision floating-point type.
Definition: half.h:126
std::istream & operator>>(std::istream &stream, half_t &x)
Definition: core_io.h:53
ScalarIO(T value)
Constructs from a value.
Definition: core_io.h:78
ScalarIO()
Default ctor.
Definition: core_io.h:75
Helper to enable formatted printing of CUTLASS scalar types to an ostream.
Definition: core_io.h:69
Top-level include for all CUTLASS numeric types.
T value
Value to print.
Definition: core_io.h:72
std::ostream & operator<<(std::ostream &out, complex< T > const &z)
Definition: complex.h:291
Generated by 1.8.11