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
torch-cluster
Commits
6ed9c162
Commit
6ed9c162
authored
Apr 09, 2018
by
rusty1s
Browse files
impl floor with scalar convert
parent
df57d3a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
aten/THC/THCGrid.cu
aten/THC/THCGrid.cu
+4
-1
aten/THC/THCNumerics.cuh
aten/THC/THCNumerics.cuh
+0
-2
No files found.
aten/THC/THCGrid.cu
View file @
6ed9c162
...
@@ -8,9 +8,12 @@ __global__ void gridKernel(int64_t *self, TensorInfo<T> posInfo, T *size,
...
@@ -8,9 +8,12 @@ __global__ void gridKernel(int64_t *self, TensorInfo<T> posInfo, T *size,
int64_t
*
count
,
ptrdiff_t
nNodes
)
{
int64_t
*
count
,
ptrdiff_t
nNodes
)
{
KERNEL_LOOP
(
i
,
nNodes
)
{
KERNEL_LOOP
(
i
,
nNodes
)
{
T
*
pos
=
posInfo
.
data
+
i
*
posInfo
.
stride
[
0
];
T
*
pos
=
posInfo
.
data
+
i
*
posInfo
.
stride
[
0
];
T
c
;
int64_t
coef
=
1
,
value
=
0
;
int64_t
coef
=
1
,
value
=
0
;
for
(
ptrdiff_t
d
=
0
;
d
<
posInfo
.
size
[
1
];
d
+=
posInfo
.
stride
[
1
])
{
for
(
ptrdiff_t
d
=
0
;
d
<
posInfo
.
size
[
1
];
d
+=
posInfo
.
stride
[
1
])
{
value
+=
coef
*
THCNumerics
<
T
>::
floor
(
THCNumerics
<
T
>::
div
(
pos
[
d
],
size
[
d
]));
c
=
THCNumerics
<
T
>::
div
(
pos
[
d
],
size
[
d
]);
c
=
ScalarConvert
<
int64_t
,
T
>::
to
(
ScalarConvert
<
T
,
int64_t
>::
to
(
c
));
// floor.
value
+=
coef
*
c
;
coef
*=
count
[
d
];
coef
*=
count
[
d
];
}
}
self
[
i
]
=
value
;
self
[
i
]
=
value
;
...
...
aten/THC/THCNumerics.cuh
View file @
6ed9c162
...
@@ -17,7 +17,6 @@ template<typename T>
...
@@ -17,7 +17,6 @@ template<typename T>
struct
THCNumerics
{
struct
THCNumerics
{
static
inline
__host__
__device__
T
div
(
T
a
,
T
b
)
{
return
a
/
b
;
}
static
inline
__host__
__device__
T
div
(
T
a
,
T
b
)
{
return
a
/
b
;
}
static
inline
__host__
__device__
bool
gt
(
T
a
,
T
b
)
{
return
a
>
b
;
}
static
inline
__host__
__device__
bool
gt
(
T
a
,
T
b
)
{
return
a
>
b
;
}
static
inline
__host__
__device__
int
floor
(
T
a
)
{
return
a
;
}
};
};
#ifdef CUDA_HALF_TENSOR
#ifdef CUDA_HALF_TENSOR
...
@@ -25,7 +24,6 @@ template<>
...
@@ -25,7 +24,6 @@ template<>
struct
THCNumerics
<
half
>
{
struct
THCNumerics
<
half
>
{
static
inline
__host__
__device__
half
div
(
half
a
,
half
b
)
{
return
f2h
(
h2f
(
a
)
/
h2f
(
b
));
}
static
inline
__host__
__device__
half
div
(
half
a
,
half
b
)
{
return
f2h
(
h2f
(
a
)
/
h2f
(
b
));
}
static
inline
__host__
__device__
bool
gt
(
half
a
,
half
b
)
{
return
h2f
(
a
)
>
h2f
(
b
);
}
static
inline
__host__
__device__
bool
gt
(
half
a
,
half
b
)
{
return
h2f
(
a
)
>
h2f
(
b
);
}
static
inline
__host__
__device__
int
floor
(
half
a
)
{
return
(
int
)
h2f
(
a
);
}
};
};
#endif // CUDA_HALF_TENSOR
#endif // CUDA_HALF_TENSOR
...
...
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