@@ -894,8 +894,11 @@ struct vector
894
894
__init(vector< T,N> value);
895
895
}
896
896
897
+ const int kRowMajorMatrixLayout = $(SLANG_MATRIX_LAYOUT_ROW_MAJOR);
898
+ const int kColumnMajorMatrixLayout = $(SLANG_MATRIX_LAYOUT_COLUMN_MAJOR);
899
+
897
900
/// A matrix with `R` rows and `C` columns, with elements of type `T`.
898
- __generic < T = float , let R : int = 4 , let C : int = 4 >
901
+ __generic < T = float , let R : int = 4 , let C : int = 4 , let L : int = $(SLANG_MATRIX_LAYOUT_MODE_UNKNOWN) >
899
902
__magic_type(MatrixExpressionType)
900
903
struct matrix
901
904
{
@@ -1111,7 +1114,7 @@ for (int tt = 0; tt < kBaseTypeCount; ++tt)
1111
1114
for ( int R = 2 ; R <= 4 ; ++ R )
1112
1115
for ( int C = 2 ; C <= 4 ; ++ C )
1113
1116
{
1114
- sb << " __generic<T> __extension matrix<T, " << R << " ," << C << " >\n {\n " ;
1117
+ sb << " __generic<T, let L:int > __extension matrix<T, " << R << " ," << C << " , L >\n {\n " ;
1115
1118
1116
1119
// initialize from R*C scalars
1117
1120
sb << " __intrinsic_op(" << int (kIROp_MakeMatrix ) << " ) __init(" ;
@@ -1137,7 +1140,7 @@ for( int C = 2; C <= 4; ++C )
1137
1140
for ( int cc = C; cc <= 4 ; ++ cc )
1138
1141
{
1139
1142
if (rr == R && cc == C) continue ;
1140
- sb << " __intrinsic_op(" << int (kIROp_MatrixReshape ) << " ) __init(matrix<T," << rr << " ," << cc << " > value);\n " ;
1143
+ sb << " __intrinsic_op(" << int (kIROp_MatrixReshape ) << " ) __init(matrix<T," << rr << " ," << cc << " , L > value);\n " ;
1141
1144
}
1142
1145
sb << " }\n " ;
1143
1146
}
@@ -1207,16 +1210,16 @@ extension vector<T, N> : IDifferentiable
1207
1210
}
1208
1211
}
1209
1212
1210
- __generic < T:__BuiltinFloatingPointType, let R: int , let C: int >
1211
- extension matrix< T, R, C> : IDifferentiable
1213
+ __generic < T:__BuiltinFloatingPointType, let R: int , let C: int , let L : int >
1214
+ extension matrix< T, R, C, L > : IDifferentiable
1212
1215
{
1213
- typedef matrix< T, R, C> Differential;
1216
+ typedef matrix< T, R, C, L > Differential;
1214
1217
1215
1218
[__unsafeForceInlineEarly]
1216
1219
[BackwardDifferentiable]
1217
1220
static Differential dzero()
1218
1221
{
1219
- return matrix< T, R, C> (__slang_noop_cast< T> (T .dzero ()));
1222
+ return matrix< T, R, C, L > (__slang_noop_cast< T> (T .dzero ()));
1220
1223
}
1221
1224
1222
1225
[__unsafeForceInlineEarly]
@@ -2425,9 +2428,9 @@ vector<T,N> operator$(op.name)(in out vector<T,N> value)
2425
2428
{$(fixity .bodyPrefix ) value = value $(op .binOp ) T(1 ); return $(fixity .returnVal ); }
2426
2429
2427
2430
$(fixity .qual )
2428
- __generic < T : __BuiltinArithmeticType, let R : int , let C : int >
2431
+ __generic < T : __BuiltinArithmeticType, let R : int , let C : int , let L : int >
2429
2432
[__unsafeForceInlineEarly]
2430
- matrix< T,R,C> operator$(op .name )(in out matrix< T,R,C> value)
2433
+ matrix< T,R,C> operator$(op .name )(in out matrix< T,R,C,L > value)
2431
2434
{$(fixity .bodyPrefix ) value = value $(op .binOp ) T(1 ); return $(fixity .returnVal ); }
2432
2435
2433
2436
$(fixity .qual )
@@ -2609,9 +2612,9 @@ __generic<L: __BuiltinIntegerType, R: __BuiltinIntegerType, let N : int, let M :
2609
2612
__intrinsic_op($(info .op ))
2610
2613
matrix< L,N,M> operator$(info .name )(matrix< L,N,M> left, matrix< R,N,M> right);
2611
2614
2612
- __generic < L: __BuiltinIntegerType, R: __BuiltinIntegerType, let N : int , let M : int >
2615
+ __generic < L: __BuiltinIntegerType, R: __BuiltinIntegerType, let N : int , let M : int , let Layout : int >
2613
2616
[__unsafeForceInlineEarly]
2614
- matrix< L, N, M> operator$(info .name )= (in out matrix< L, N, M> left, matrix< R, N, M> right)
2617
+ matrix< L, N, M> operator$(info .name )= (in out matrix< L, N, M, Layout > left, matrix< R, N, M> right)
2615
2618
{
2616
2619
left = left $(info .name ) right;
2617
2620
return left;
@@ -2641,9 +2644,9 @@ __generic<L: __BuiltinIntegerType, R: __BuiltinIntegerType, let N : int, let M :
2641
2644
__intrinsic_op($(info .op ))
2642
2645
matrix< L,N,M> operator$(info .name )(matrix< L,N,M> left, R right);
2643
2646
2644
- __generic < L: __BuiltinIntegerType, R: __BuiltinIntegerType, let N : int , let M : int >
2647
+ __generic < L: __BuiltinIntegerType, R: __BuiltinIntegerType, let N : int , let M : int , let Layout : int >
2645
2648
[__unsafeForceInlineEarly]
2646
- matrix< L,N,M> operator$(info .name )= (in out matrix< L,N,M> left, R right)
2649
+ matrix< L,N,M> operator$(info .name )= (in out matrix< L,N,M, Layout > left, R right)
2647
2650
{
2648
2651
left = left $(info .name ) right;
2649
2652
return left;
@@ -2696,17 +2699,17 @@ ${{{{
2696
2699
return left;
2697
2700
}
2698
2701
2699
- __generic < T : $(op .interface ), let R : int , let C : int >
2702
+ __generic < T : $(op .interface ), let R : int , let C : int , let Layout : int >
2700
2703
[__unsafeForceInlineEarly]
2701
- matrix< T,R,C> operator$(op .name )= (in out matrix< T,R,C> left, matrix< T,R,C> right)
2704
+ matrix< T,R,C> operator$(op .name )= (in out matrix< T,R,C,Layout > left, matrix< T,R,C> right)
2702
2705
{
2703
2706
left = left $(op .name ) right;
2704
2707
return left;
2705
2708
}
2706
2709
2707
- __generic < T : $(op .interface ), let R : int , let C : int >
2710
+ __generic < T : $(op .interface ), let R : int , let C : int , let Layout : int >
2708
2711
[__unsafeForceInlineEarly]
2709
- matrix< T,R,C> operator$(op .name )= (in out matrix< T,R,C> left, T right)
2712
+ matrix< T,R,C> operator$(op .name )= (in out matrix< T,R,C, Layout > left, T right)
2710
2713
{
2711
2714
left = left $(op .name ) right;
2712
2715
return left;
0 commit comments