core_io.h
Go to the documentation of this file.
/***************************************************************************************************
* Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
* * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************************************/
#pragma once
#include <iostream>
#include <typeinfo>
#include "cutlass/coord.h"
#include "cutlass/numeric_types.h"
namespace cutlass {
template <int Rank>
inline
std::ostream& operator<<(std::ostream& out, Coord<Rank> const& coord) {
for (int i = 0; i < Rank; ++i) {
out << (i ? ", " : "") << coord[i];
}
return out;
}
inline
std::istream & operator>>(std::istream &stream, half_t &x) {
float tmp;
stream >> tmp;
x = static_cast< cutlass::half_t >(tmp);
return stream;
}
inline
std::ostream & operator<<(std::ostream &out, half_t const &x) {
return out << float(x);
}
template <typename T>
struct ScalarIO {
T value;
ScalarIO() { }
ScalarIO(T value): value(value) {}
};
template <typename T>
inline std::ostream &operator<<(std::ostream &out, ScalarIO<T> const &scalar) {
return out << scalar.value;
}
template <>
inline std::ostream &operator<<(std::ostream &out, ScalarIO<int8_t> const &scalar) {
return out << int(scalar.value);
}
template <>
inline std::ostream &operator<<(std::ostream &out, ScalarIO<uint8_t> const &scalar) {
return out << unsigned(scalar.value);
}
} // namespace cutlass
cutlass
Definition: aligned_buffer.h:35
coord.h
A Coord is a coordinate of arbitrary rank into a tensor or matrix.
cutlass::half_t
IEEE half-precision floating-point type.
Definition: half.h:126
cutlass::operator>>
std::istream & operator>>(std::istream &stream, half_t &x)
Definition: core_io.h:53
cutlass::ScalarIO::ScalarIO
ScalarIO(T value)
Constructs from a value.
Definition: core_io.h:78
cutlass::ScalarIO::ScalarIO
ScalarIO()
Default ctor.
Definition: core_io.h:75
cutlass::ScalarIO
Helper to enable formatted printing of CUTLASS scalar types to an ostream.
Definition: core_io.h:69
numeric_types.h
Top-level include for all CUTLASS numeric types.
cutlass::ScalarIO::value
T value
Value to print.
Definition: core_io.h:72
cutlass::operator<<
std::ostream & operator<<(std::ostream &out, complex< T > const &z)
Definition: complex.h:291