| CUTLASS CUDA Templates for Linear Algebra Subroutines and Solvers

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

matrix_coord.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 **************************************************************************************************/
28 #pragma once
29
30 #include "cutlass/cutlass.h"
31 #include "cutlass/coord.h"
32
33 namespace cutlass {
34
36
39 struct MatrixCoord : public Coord<2, int> {
40
41 public:
42
44 using Index = int;
45
47 using Base = Coord<2, Index>;
48
49 private:
50
52 static int const kRow = 0;
53
55 static int const kColumn = 1;
56
57 public:
58
59 //
60 // Methods
61 //
62
64 CUTLASS_HOST_DEVICE
65 MatrixCoord() { }
66
68 CUTLASS_HOST_DEVICE
69 MatrixCoord(Coord<2, Index> const &coord): Base(coord) { }
70
72 CUTLASS_HOST_DEVICE
73 MatrixCoord(Index row, Index column): Base(make_Coord(row, column)) { }
74
76 CUTLASS_HOST_DEVICE
77 Index const & row() const { return this->at(kRow); }
78
80 CUTLASS_HOST_DEVICE
81 Index & row() { return this->at(kRow); }
82
84 CUTLASS_HOST_DEVICE
85 Index const & column() const { return this->at(kColumn); }
86
88 CUTLASS_HOST_DEVICE
89 Index & column() { return this->at(kColumn); }
90
91 //
92 // Coord operators
93 //
94
96 CUTLASS_HOST_DEVICE
97 MatrixCoord operator+(Base const& b) const {
98 return MatrixCoord(Base::operator+(b));
99 }
100
102 CUTLASS_HOST_DEVICE
103 MatrixCoord operator-(Base const& b) const {
104 return MatrixCoord(Base::operator-(b));
105 }
106
108 CUTLASS_HOST_DEVICE
109 MatrixCoord operator*(Base const& b) const {
110 return MatrixCoord(Base::operator*(b));
111 }
112
114 CUTLASS_HOST_DEVICE
115 MatrixCoord operator/(Base const& b) const {
116 return MatrixCoord(Base::operator/(b));
117 }
118
120 CUTLASS_HOST_DEVICE
121 MatrixCoord& operator+=(Base const& b) {
122 Base::operator+=(b);
123 return *this;
124 }
125
127 CUTLASS_HOST_DEVICE
128 MatrixCoord& operator-=(Base const& b) {
129 Base::operator-=(b);
130 return *this;
131 }
132
134 CUTLASS_HOST_DEVICE
135 MatrixCoord& operator*=(Base const& b) {
136 Base::operator*=(b);
137 return *this;
138 }
139
141 CUTLASS_HOST_DEVICE
142 MatrixCoord& operator/=(Base const& b) {
143 Base::operator/=(b);
144 return *this;
145 }
146
147 };
148
150
151 } // namespace cutlass
cutlass::MatrixCoord::column
CUTLASS_HOST_DEVICE Index const & column() const
Returns the column of the coordinate.
Definition: matrix_coord.h:85
cutlass
Definition: aligned_buffer.h:35
cutlass::MatrixCoord::operator-
CUTLASS_HOST_DEVICE MatrixCoord operator-(Base const &b) const
Element-wise subtraction.
Definition: matrix_coord.h:103
cutlass::Coord::operator*=
CUTLASS_HOST_DEVICE Coord & operator*=(Coord const &b)
In-place multiplication.
Definition: coord.h:222
cutlass::MatrixCoord::operator*
CUTLASS_HOST_DEVICE MatrixCoord operator*(Base const &b) const
Element-wise multiplication.
Definition: matrix_coord.h:109
coord.h
A Coord is a coordinate of arbitrary rank into a tensor or matrix.
cutlass::make_Coord
CUTLASS_HOST_DEVICE Coord< 1 > make_Coord(int _0)
Helper to make a 2-element coordinate.
Definition: coord.h:387
cutlass::MatrixCoord::operator/=
CUTLASS_HOST_DEVICE MatrixCoord & operator/=(Base const &b)
In-place division.
Definition: matrix_coord.h:142
cutlass::MatrixCoord::row
CUTLASS_HOST_DEVICE Index const & row() const
Returns the row of the coordinate.
Definition: matrix_coord.h:77
cutlass::Coord::operator-=
CUTLASS_HOST_DEVICE Coord & operator-=(Coord const &b)
In-place subtraction.
Definition: coord.h:213
cutlass::MatrixCoord::operator+
CUTLASS_HOST_DEVICE MatrixCoord operator+(Base const &b) const
Element-wise addition.
Definition: matrix_coord.h:97
cutlass::MatrixCoord::MatrixCoord
CUTLASS_HOST_DEVICE MatrixCoord(Index row, Index column)
Helper to construct from a row and column.
Definition: matrix_coord.h:73
CUTLASS_HOST_DEVICE
#define CUTLASS_HOST_DEVICE
Definition: cutlass.h:89
cutlass::Coord::operator/=
CUTLASS_HOST_DEVICE Coord & operator/=(Coord const &b)
In-place division.
Definition: coord.h:231
cutlass::MatrixCoord::MatrixCoord
CUTLASS_HOST_DEVICE MatrixCoord(Coord< 2, Index > const &coord)
Constructs from Coord<2>
Definition: matrix_coord.h:69
cutlass::Coord
Statically-sized array specifying Coords within a tensor.
Definition: coord.h:43
cutlass::MatrixCoord::Index
int Index
Integer-valued index.
Definition: matrix_coord.h:44
cutlass::MatrixCoord::operator-=
CUTLASS_HOST_DEVICE MatrixCoord & operator-=(Base const &b)
In-place subtraction.
Definition: matrix_coord.h:128
cutlass::MatrixCoord::row
CUTLASS_HOST_DEVICE Index & row()
Returns the row of the coordinate.
Definition: matrix_coord.h:81
cutlass::Coord::operator+=
CUTLASS_HOST_DEVICE Coord & operator+=(Coord const &b)
In-place addition.
Definition: coord.h:204
cutlass::MatrixCoord::operator/
CUTLASS_HOST_DEVICE MatrixCoord operator/(Base const &b) const
Element-wise division.
Definition: matrix_coord.h:115
cutlass::Coord< 2, int >::at
CUTLASS_HOST_DEVICE Index & at()
Gets the index of a given Coord element.
Definition: coord.h:255
cutlass::MatrixCoord::column
CUTLASS_HOST_DEVICE Index & column()
Returns the column of the coordinate.
Definition: matrix_coord.h:89
cutlass::MatrixCoord::operator*=
CUTLASS_HOST_DEVICE MatrixCoord & operator*=(Base const &b)
In-place multiplication.
Definition: matrix_coord.h:135
cutlass::MatrixCoord::operator+=
CUTLASS_HOST_DEVICE MatrixCoord & operator+=(Base const &b)
In-place addition.
Definition: matrix_coord.h:121
cutlass.h
Basic include for CUTLASS.
cutlass::MatrixCoord
Definition: matrix_coord.h:39
cutlass::MatrixCoord::MatrixCoord
CUTLASS_HOST_DEVICE MatrixCoord()
Default ctor.
Definition: matrix_coord.h:65