Back to Cutlass

CUTLASS: matrix_coord.h Source File

docs/matrix__coord_8h_source.html

4.4.215.2 KB
Original Source

| | CUTLASS

CUDA Templates for Linear Algebra Subroutines and Solvers |

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

44using Index = int;

45

47using Base = Coord<2, Index>;

48

49 private:

50

52static int const kRow = 0;

53

55static int const kColumn = 1;

56

57 public:

58

59//

60// Methods

61//

62

64CUTLASS_HOST_DEVICE

65MatrixCoord() { }

66

68CUTLASS_HOST_DEVICE

69MatrixCoord(Coord<2, Index> const &coord): Base(coord) { }

70

72CUTLASS_HOST_DEVICE

73MatrixCoord(Index row, Index column): Base(make_Coord(row, column)) { }

74

76CUTLASS_HOST_DEVICE

77Index const & row() const { return this->at(kRow); }

78

80CUTLASS_HOST_DEVICE

81Index & row() { return this->at(kRow); }

82

84CUTLASS_HOST_DEVICE

85Index const & column() const { return this->at(kColumn); }

86

88CUTLASS_HOST_DEVICE

89Index & column() { return this->at(kColumn); }

90

91//

92// Coord operators

93//

94

96CUTLASS_HOST_DEVICE

97MatrixCoord operator+(Base const& b) const {

98return MatrixCoord(Base::operator+(b));

99 }

100

102CUTLASS_HOST_DEVICE

103MatrixCoord operator-(Base const& b) const {

104return MatrixCoord(Base::operator-(b));

105 }

106

108CUTLASS_HOST_DEVICE

109MatrixCoord operator*(Base const& b) const {

110return MatrixCoord(Base::operator*(b));

111 }

112

114CUTLASS_HOST_DEVICE

115MatrixCoord operator/(Base const& b) const {

116return MatrixCoord(Base::operator/(b));

117 }

118

120CUTLASS_HOST_DEVICE

121MatrixCoord& operator+=(Base const& b) {

122Base::operator+=(b);

123return *this;

124 }

125

127CUTLASS_HOST_DEVICE

128MatrixCoord& operator-=(Base const& b) {

129Base::operator-=(b);

130return *this;

131 }

132

134CUTLASS_HOST_DEVICE

135MatrixCoord& operator*=(Base const& b) {

136Base::operator*=(b);

137return *this;

138 }

139

141CUTLASS_HOST_DEVICE

142MatrixCoord& operator/=(Base const& b) {

143Base::operator/=(b);

144return *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


Generated by 1.8.11