Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
apex
Commits
0f5e3fe0
Commit
0f5e3fe0
authored
Mar 07, 2019
by
Syed Tousif Ahmed
Browse files
Use build macro for backward compat
parent
2a467090
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
csrc/layer_norm_cuda.cpp
csrc/layer_norm_cuda.cpp
+40
-0
csrc/layer_norm_cuda_kernel.cu
csrc/layer_norm_cuda_kernel.cu
+8
-0
No files found.
csrc/layer_norm_cuda.cpp
View file @
0f5e3fe0
...
@@ -5,7 +5,11 @@
...
@@ -5,7 +5,11 @@
namespace
{
namespace
{
void
compute_n1_n2
(
void
compute_n1_n2
(
at
::
Tensor
input
,
at
::
Tensor
input
,
#ifdef VERSION_GE_1_1
at
::
IntArrayRef
normalized_shape
,
at
::
IntArrayRef
normalized_shape
,
#else
at
::
IntList
normalized_shape
,
#endif
int
&
n1
,
int
&
n1
,
int
&
n2
)
int
&
n2
)
{
{
...
@@ -22,7 +26,11 @@ void compute_n1_n2(
...
@@ -22,7 +26,11 @@ void compute_n1_n2(
}
}
void
check_args
(
void
check_args
(
#ifdef VERSION_GE_1_1
at
::
IntArrayRef
normalized_shape
,
at
::
IntArrayRef
normalized_shape
,
#else
at
::
IntList
normalized_shape
,
#endif
at
::
Tensor
gamma
,
at
::
Tensor
gamma
,
at
::
Tensor
beta
at
::
Tensor
beta
)
)
...
@@ -33,7 +41,11 @@ void check_args(
...
@@ -33,7 +41,11 @@ void check_args(
void
check_args
(
void
check_args
(
at
::
Tensor
input
,
at
::
Tensor
input
,
#ifdef VERSION_GE_1_1
at
::
IntArrayRef
normalized_shape
,
at
::
IntArrayRef
normalized_shape
,
#else
at
::
IntList
normalized_shape
,
#endif
int
&
n1
,
int
&
n1
,
int
&
n2
int
&
n2
)
)
...
@@ -69,7 +81,11 @@ void check_args(
...
@@ -69,7 +81,11 @@ void check_args(
void
check_args
(
void
check_args
(
at
::
Tensor
input
,
at
::
Tensor
input
,
#ifdef VERSION_GE_1_1
at
::
IntArrayRef
normalized_shape
,
at
::
IntArrayRef
normalized_shape
,
#else
at
::
IntList
normalized_shape
,
#endif
at
::
Tensor
gamma
,
at
::
Tensor
gamma
,
at
::
Tensor
beta
,
at
::
Tensor
beta
,
int
&
n1
,
int
&
n1
,
...
@@ -88,7 +104,11 @@ void cuda_layer_norm(
...
@@ -88,7 +104,11 @@ void cuda_layer_norm(
at
::
Tensor
*
input
,
at
::
Tensor
*
input
,
int
n1
,
int
n1
,
int
n2
,
int
n2
,
#ifdef VERSION_GE_1_1
at
::
IntArrayRef
normalized_shape
,
at
::
IntArrayRef
normalized_shape
,
#else
at
::
IntList
normalized_shape
,
#endif
at
::
Tensor
*
gamma
,
at
::
Tensor
*
gamma
,
at
::
Tensor
*
beta
,
at
::
Tensor
*
beta
,
double
epsilon
);
double
epsilon
);
...
@@ -99,7 +119,11 @@ void cuda_layer_norm(
...
@@ -99,7 +119,11 @@ void cuda_layer_norm(
std
::
vector
<
at
::
Tensor
>
layer_norm
(
std
::
vector
<
at
::
Tensor
>
layer_norm
(
at
::
Tensor
input
,
at
::
Tensor
input
,
#ifdef VERSION_GE_1_1
at
::
IntArrayRef
normalized_shape
,
at
::
IntArrayRef
normalized_shape
,
#else
at
::
IntList
normalized_shape
,
#endif
double
epsilon
)
{
double
epsilon
)
{
CHECK_INPUT
(
input
);
CHECK_INPUT
(
input
);
int
n1
,
n2
;
int
n1
,
n2
;
...
@@ -113,7 +137,11 @@ std::vector<at::Tensor> layer_norm(
...
@@ -113,7 +137,11 @@ std::vector<at::Tensor> layer_norm(
}
}
std
::
vector
<
at
::
Tensor
>
layer_norm_affine
(
std
::
vector
<
at
::
Tensor
>
layer_norm_affine
(
at
::
Tensor
input
,
at
::
Tensor
input
,
#ifdef VERSION_GE_1_1
at
::
IntArrayRef
normalized_shape
,
at
::
IntArrayRef
normalized_shape
,
#else
at
::
IntList
normalized_shape
,
#endif
at
::
Tensor
gamma
,
at
::
Tensor
gamma
,
at
::
Tensor
beta
,
at
::
Tensor
beta
,
double
epsilon
)
{
double
epsilon
)
{
...
@@ -137,7 +165,11 @@ void cuda_layer_norm_gradient(
...
@@ -137,7 +165,11 @@ void cuda_layer_norm_gradient(
at
::
Tensor
*
input
,
at
::
Tensor
*
input
,
int
n1
,
int
n1
,
int
n2
,
int
n2
,
#ifdef VERSION_GE_1_1
at
::
IntArrayRef
normalized_shape
,
at
::
IntArrayRef
normalized_shape
,
#else
at
::
IntList
normalized_shape
,
#endif
at
::
Tensor
*
gamma
,
at
::
Tensor
*
gamma
,
at
::
Tensor
*
beta
,
at
::
Tensor
*
beta
,
double
epsilon
,
double
epsilon
,
...
@@ -151,7 +183,11 @@ at::Tensor layer_norm_gradient(
...
@@ -151,7 +183,11 @@ at::Tensor layer_norm_gradient(
at
::
Tensor
mean
,
at
::
Tensor
mean
,
at
::
Tensor
invvar
,
at
::
Tensor
invvar
,
at
::
Tensor
input
,
at
::
Tensor
input
,
#ifdef VERSION_GE_1_1
at
::
IntArrayRef
normalized_shape
,
at
::
IntArrayRef
normalized_shape
,
#else
at
::
IntList
normalized_shape
,
#endif
double
epsilon
)
{
double
epsilon
)
{
CHECK_INPUT
(
dout
);
CHECK_INPUT
(
dout
);
CHECK_INPUT
(
mean
);
CHECK_INPUT
(
mean
);
...
@@ -170,7 +206,11 @@ std::vector<at::Tensor> layer_norm_gradient_affine(
...
@@ -170,7 +206,11 @@ std::vector<at::Tensor> layer_norm_gradient_affine(
at
::
Tensor
mean
,
at
::
Tensor
mean
,
at
::
Tensor
invvar
,
at
::
Tensor
invvar
,
at
::
Tensor
input
,
at
::
Tensor
input
,
#ifdef VERSION_GE_1_1
at
::
IntArrayRef
normalized_shape
,
at
::
IntArrayRef
normalized_shape
,
#else
at
::
IntList
normalized_shape
,
#endif
at
::
Tensor
gamma
,
at
::
Tensor
gamma
,
at
::
Tensor
beta
,
at
::
Tensor
beta
,
double
epsilon
)
{
double
epsilon
)
{
...
...
csrc/layer_norm_cuda_kernel.cu
View file @
0f5e3fe0
...
@@ -672,7 +672,11 @@ void cuda_layer_norm(
...
@@ -672,7 +672,11 @@ void cuda_layer_norm(
at
::
Tensor
*
input
,
at
::
Tensor
*
input
,
int
n1
,
int
n1
,
int
n2
,
int
n2
,
#ifdef VERSION_GE_1_1
at
::
IntArrayRef
normalized_shape
,
at
::
IntArrayRef
normalized_shape
,
#else
at
::
IntList
normalized_shape
,
#endif
at
::
Tensor
*
gamma
,
at
::
Tensor
*
gamma
,
at
::
Tensor
*
beta
,
at
::
Tensor
*
beta
,
double
epsilon
)
double
epsilon
)
...
@@ -767,7 +771,11 @@ void cuda_layer_norm_gradient(
...
@@ -767,7 +771,11 @@ void cuda_layer_norm_gradient(
at
::
Tensor
*
input
,
at
::
Tensor
*
input
,
int
n1
,
int
n1
,
int
n2
,
int
n2
,
#ifdef VERSION_GE_1_1
at
::
IntArrayRef
normalized_shape
,
at
::
IntArrayRef
normalized_shape
,
#else
at
::
IntList
normalized_shape
,
#endif
at
::
Tensor
*
gamma
,
at
::
Tensor
*
gamma
,
at
::
Tensor
*
beta
,
at
::
Tensor
*
beta
,
double
epsilon
,
double
epsilon
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment