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
vision
Commits
c6e41b5d
Commit
c6e41b5d
authored
Aug 29, 2019
by
Yuxin Wu
Committed by
Francisco Massa
Aug 29, 2019
Browse files
Use Tensor.data_ptr instead of .data (#1262)
* Use Tensor.data_ptr instead of .data * use pytorch-nightly in CI
parent
4b040a65
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
41 deletions
+41
-41
.travis.yml
.travis.yml
+1
-1
torchvision/csrc/cpu/ROIAlign_cpu.cpp
torchvision/csrc/cpu/ROIAlign_cpu.cpp
+6
-6
torchvision/csrc/cpu/ROIPool_cpu.cpp
torchvision/csrc/cpu/ROIPool_cpu.cpp
+8
-8
torchvision/csrc/cpu/nms_cpu.cpp
torchvision/csrc/cpu/nms_cpu.cpp
+8
-8
torchvision/csrc/cuda/ROIAlign_cuda.cu
torchvision/csrc/cuda/ROIAlign_cuda.cu
+6
-6
torchvision/csrc/cuda/ROIPool_cuda.cu
torchvision/csrc/cuda/ROIPool_cuda.cu
+8
-8
torchvision/csrc/cuda/nms_cuda.cu
torchvision/csrc/cuda/nms_cuda.cu
+4
-4
No files found.
.travis.yml
View file @
c6e41b5d
...
@@ -26,7 +26,7 @@ before_install:
...
@@ -26,7 +26,7 @@ before_install:
# Useful for debugging any issues with conda
# Useful for debugging any issues with conda
-
conda info -a
-
conda info -a
-
conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pytorch scipy -c pytorch
-
conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pytorch scipy -c pytorch
-nightly
-
source activate test-environment
-
source activate test-environment
-
|
-
|
if [[ "$IMAGE_BACKEND" == "Pillow-SIMD" ]]; then
if [[ "$IMAGE_BACKEND" == "Pillow-SIMD" ]]; then
...
...
torchvision/csrc/cpu/ROIAlign_cpu.cpp
View file @
c6e41b5d
...
@@ -406,7 +406,7 @@ at::Tensor ROIAlign_forward_cpu(
...
@@ -406,7 +406,7 @@ at::Tensor ROIAlign_forward_cpu(
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
input
.
type
(),
"ROIAlign_forward"
,
[
&
]
{
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
input
.
type
(),
"ROIAlign_forward"
,
[
&
]
{
ROIAlignForward
<
scalar_t
>
(
ROIAlignForward
<
scalar_t
>
(
output_size
,
output_size
,
input
.
contiguous
().
data
<
scalar_t
>
(),
input
.
contiguous
().
data
_ptr
<
scalar_t
>
(),
spatial_scale
,
spatial_scale
,
channels
,
channels
,
height
,
height
,
...
@@ -414,8 +414,8 @@ at::Tensor ROIAlign_forward_cpu(
...
@@ -414,8 +414,8 @@ at::Tensor ROIAlign_forward_cpu(
pooled_height
,
pooled_height
,
pooled_width
,
pooled_width
,
sampling_ratio
,
sampling_ratio
,
rois
.
contiguous
().
data
<
scalar_t
>
(),
rois
.
contiguous
().
data
_ptr
<
scalar_t
>
(),
output
.
data
<
scalar_t
>
());
output
.
data
_ptr
<
scalar_t
>
());
});
});
return
output
;
return
output
;
}
}
...
@@ -456,7 +456,7 @@ at::Tensor ROIAlign_backward_cpu(
...
@@ -456,7 +456,7 @@ at::Tensor ROIAlign_backward_cpu(
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
grad
.
type
(),
"ROIAlign_forward"
,
[
&
]
{
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
grad
.
type
(),
"ROIAlign_forward"
,
[
&
]
{
ROIAlignBackward
<
scalar_t
>
(
ROIAlignBackward
<
scalar_t
>
(
grad
.
numel
(),
grad
.
numel
(),
grad
.
data
<
scalar_t
>
(),
grad
.
data
_ptr
<
scalar_t
>
(),
spatial_scale
,
spatial_scale
,
channels
,
channels
,
height
,
height
,
...
@@ -464,8 +464,8 @@ at::Tensor ROIAlign_backward_cpu(
...
@@ -464,8 +464,8 @@ at::Tensor ROIAlign_backward_cpu(
pooled_height
,
pooled_height
,
pooled_width
,
pooled_width
,
sampling_ratio
,
sampling_ratio
,
grad_input
.
data
<
scalar_t
>
(),
grad_input
.
data
_ptr
<
scalar_t
>
(),
rois
.
contiguous
().
data
<
scalar_t
>
(),
rois
.
contiguous
().
data
_ptr
<
scalar_t
>
(),
n_stride
,
n_stride
,
c_stride
,
c_stride
,
h_stride
,
h_stride
,
...
...
torchvision/csrc/cpu/ROIPool_cpu.cpp
View file @
c6e41b5d
...
@@ -151,17 +151,17 @@ std::tuple<at::Tensor, at::Tensor> ROIPool_forward_cpu(
...
@@ -151,17 +151,17 @@ std::tuple<at::Tensor, at::Tensor> ROIPool_forward_cpu(
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
input
.
type
(),
"ROIPool_forward"
,
[
&
]
{
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
input
.
type
(),
"ROIPool_forward"
,
[
&
]
{
RoIPoolForward
<
scalar_t
>
(
RoIPoolForward
<
scalar_t
>
(
input
.
contiguous
().
data
<
scalar_t
>
(),
input
.
contiguous
().
data
_ptr
<
scalar_t
>
(),
spatial_scale
,
spatial_scale
,
channels
,
channels
,
height
,
height
,
width
,
width
,
pooled_height
,
pooled_height
,
pooled_width
,
pooled_width
,
rois
.
contiguous
().
data
<
scalar_t
>
(),
rois
.
contiguous
().
data
_ptr
<
scalar_t
>
(),
num_rois
,
num_rois
,
output
.
data
<
scalar_t
>
(),
output
.
data
_ptr
<
scalar_t
>
(),
argmax
.
data
<
int
>
());
argmax
.
data
_ptr
<
int
>
());
});
});
return
std
::
make_tuple
(
output
,
argmax
);
return
std
::
make_tuple
(
output
,
argmax
);
}
}
...
@@ -205,16 +205,16 @@ at::Tensor ROIPool_backward_cpu(
...
@@ -205,16 +205,16 @@ at::Tensor ROIPool_backward_cpu(
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
grad
.
type
(),
"ROIPool_backward"
,
[
&
]
{
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
grad
.
type
(),
"ROIPool_backward"
,
[
&
]
{
RoIPoolBackward
<
scalar_t
>
(
RoIPoolBackward
<
scalar_t
>
(
grad
.
data
<
scalar_t
>
(),
grad
.
data
_ptr
<
scalar_t
>
(),
argmax
.
data
<
int
>
(),
argmax
.
data
_ptr
<
int
>
(),
num_rois
,
num_rois
,
channels
,
channels
,
height
,
height
,
width
,
width
,
pooled_height
,
pooled_height
,
pooled_width
,
pooled_width
,
grad_input
.
data
<
scalar_t
>
(),
grad_input
.
data
_ptr
<
scalar_t
>
(),
rois
.
contiguous
().
data
<
scalar_t
>
(),
rois
.
contiguous
().
data
_ptr
<
scalar_t
>
(),
n_stride
,
n_stride
,
c_stride
,
c_stride
,
h_stride
,
h_stride
,
...
...
torchvision/csrc/cpu/nms_cpu.cpp
View file @
c6e41b5d
...
@@ -26,14 +26,14 @@ at::Tensor nms_cpu_kernel(
...
@@ -26,14 +26,14 @@ at::Tensor nms_cpu_kernel(
at
::
Tensor
suppressed_t
=
at
::
zeros
({
ndets
},
dets
.
options
().
dtype
(
at
::
kByte
));
at
::
Tensor
suppressed_t
=
at
::
zeros
({
ndets
},
dets
.
options
().
dtype
(
at
::
kByte
));
at
::
Tensor
keep_t
=
at
::
zeros
({
ndets
},
dets
.
options
().
dtype
(
at
::
kLong
));
at
::
Tensor
keep_t
=
at
::
zeros
({
ndets
},
dets
.
options
().
dtype
(
at
::
kLong
));
auto
suppressed
=
suppressed_t
.
data
<
uint8_t
>
();
auto
suppressed
=
suppressed_t
.
data
_ptr
<
uint8_t
>
();
auto
keep
=
keep_t
.
data
<
int64_t
>
();
auto
keep
=
keep_t
.
data
_ptr
<
int64_t
>
();
auto
order
=
order_t
.
data
<
int64_t
>
();
auto
order
=
order_t
.
data
_ptr
<
int64_t
>
();
auto
x1
=
x1_t
.
data
<
scalar_t
>
();
auto
x1
=
x1_t
.
data
_ptr
<
scalar_t
>
();
auto
y1
=
y1_t
.
data
<
scalar_t
>
();
auto
y1
=
y1_t
.
data
_ptr
<
scalar_t
>
();
auto
x2
=
x2_t
.
data
<
scalar_t
>
();
auto
x2
=
x2_t
.
data
_ptr
<
scalar_t
>
();
auto
y2
=
y2_t
.
data
<
scalar_t
>
();
auto
y2
=
y2_t
.
data
_ptr
<
scalar_t
>
();
auto
areas
=
areas_t
.
data
<
scalar_t
>
();
auto
areas
=
areas_t
.
data
_ptr
<
scalar_t
>
();
int64_t
num_to_keep
=
0
;
int64_t
num_to_keep
=
0
;
...
...
torchvision/csrc/cuda/ROIAlign_cuda.cu
View file @
c6e41b5d
...
@@ -340,7 +340,7 @@ at::Tensor ROIAlign_forward_cuda(
...
@@ -340,7 +340,7 @@ at::Tensor ROIAlign_forward_cuda(
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
input
.
type
(),
"ROIAlign_forward"
,
[
&
]
{
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
input
.
type
(),
"ROIAlign_forward"
,
[
&
]
{
RoIAlignForward
<
scalar_t
><<<
grid
,
block
,
0
,
stream
>>>
(
RoIAlignForward
<
scalar_t
><<<
grid
,
block
,
0
,
stream
>>>
(
output_size
,
output_size
,
input
.
contiguous
().
data
<
scalar_t
>
(),
input
.
contiguous
().
data
_ptr
<
scalar_t
>
(),
spatial_scale
,
spatial_scale
,
channels
,
channels
,
height
,
height
,
...
@@ -348,8 +348,8 @@ at::Tensor ROIAlign_forward_cuda(
...
@@ -348,8 +348,8 @@ at::Tensor ROIAlign_forward_cuda(
pooled_height
,
pooled_height
,
pooled_width
,
pooled_width
,
sampling_ratio
,
sampling_ratio
,
rois
.
contiguous
().
data
<
scalar_t
>
(),
rois
.
contiguous
().
data
_ptr
<
scalar_t
>
(),
output
.
data
<
scalar_t
>
());
output
.
data
_ptr
<
scalar_t
>
());
});
});
AT_CUDA_CHECK
(
cudaGetLastError
());
AT_CUDA_CHECK
(
cudaGetLastError
());
return
output
;
return
output
;
...
@@ -402,7 +402,7 @@ at::Tensor ROIAlign_backward_cuda(
...
@@ -402,7 +402,7 @@ at::Tensor ROIAlign_backward_cuda(
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
grad
.
type
(),
"ROIAlign_backward"
,
[
&
]
{
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
grad
.
type
(),
"ROIAlign_backward"
,
[
&
]
{
RoIAlignBackward
<
scalar_t
><<<
grid
,
block
,
0
,
stream
>>>
(
RoIAlignBackward
<
scalar_t
><<<
grid
,
block
,
0
,
stream
>>>
(
grad
.
numel
(),
grad
.
numel
(),
grad
.
data
<
scalar_t
>
(),
grad
.
data
_ptr
<
scalar_t
>
(),
spatial_scale
,
spatial_scale
,
channels
,
channels
,
height
,
height
,
...
@@ -410,8 +410,8 @@ at::Tensor ROIAlign_backward_cuda(
...
@@ -410,8 +410,8 @@ at::Tensor ROIAlign_backward_cuda(
pooled_height
,
pooled_height
,
pooled_width
,
pooled_width
,
sampling_ratio
,
sampling_ratio
,
grad_input
.
data
<
scalar_t
>
(),
grad_input
.
data
_ptr
<
scalar_t
>
(),
rois
.
contiguous
().
data
<
scalar_t
>
(),
rois
.
contiguous
().
data
_ptr
<
scalar_t
>
(),
n_stride
,
n_stride
,
c_stride
,
c_stride
,
h_stride
,
h_stride
,
...
...
torchvision/csrc/cuda/ROIPool_cuda.cu
View file @
c6e41b5d
...
@@ -160,16 +160,16 @@ std::tuple<at::Tensor, at::Tensor> ROIPool_forward_cuda(
...
@@ -160,16 +160,16 @@ std::tuple<at::Tensor, at::Tensor> ROIPool_forward_cuda(
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
input
.
type
(),
"ROIPool_forward"
,
[
&
]
{
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
input
.
type
(),
"ROIPool_forward"
,
[
&
]
{
RoIPoolForward
<
scalar_t
><<<
grid
,
block
,
0
,
stream
>>>
(
RoIPoolForward
<
scalar_t
><<<
grid
,
block
,
0
,
stream
>>>
(
output_size
,
output_size
,
input
.
contiguous
().
data
<
scalar_t
>
(),
input
.
contiguous
().
data
_ptr
<
scalar_t
>
(),
spatial_scale
,
spatial_scale
,
channels
,
channels
,
height
,
height
,
width
,
width
,
pooled_height
,
pooled_height
,
pooled_width
,
pooled_width
,
rois
.
contiguous
().
data
<
scalar_t
>
(),
rois
.
contiguous
().
data
_ptr
<
scalar_t
>
(),
output
.
data
<
scalar_t
>
(),
output
.
data
_ptr
<
scalar_t
>
(),
argmax
.
data
<
int
>
());
argmax
.
data
_ptr
<
int
>
());
});
});
AT_CUDA_CHECK
(
cudaGetLastError
());
AT_CUDA_CHECK
(
cudaGetLastError
());
return
std
::
make_tuple
(
output
,
argmax
);
return
std
::
make_tuple
(
output
,
argmax
);
...
@@ -227,8 +227,8 @@ at::Tensor ROIPool_backward_cuda(
...
@@ -227,8 +227,8 @@ at::Tensor ROIPool_backward_cuda(
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
grad
.
type
(),
"ROIPool_backward"
,
[
&
]
{
AT_DISPATCH_FLOATING_TYPES_AND_HALF
(
grad
.
type
(),
"ROIPool_backward"
,
[
&
]
{
RoIPoolBackward
<
scalar_t
><<<
grid
,
block
,
0
,
stream
>>>
(
RoIPoolBackward
<
scalar_t
><<<
grid
,
block
,
0
,
stream
>>>
(
grad
.
numel
(),
grad
.
numel
(),
grad
.
data
<
scalar_t
>
(),
grad
.
data
_ptr
<
scalar_t
>
(),
argmax
.
contiguous
().
data
<
int
>
(),
argmax
.
contiguous
().
data
_ptr
<
int
>
(),
num_rois
,
num_rois
,
spatial_scale
,
spatial_scale
,
channels
,
channels
,
...
@@ -236,8 +236,8 @@ at::Tensor ROIPool_backward_cuda(
...
@@ -236,8 +236,8 @@ at::Tensor ROIPool_backward_cuda(
width
,
width
,
pooled_height
,
pooled_height
,
pooled_width
,
pooled_width
,
grad_input
.
data
<
scalar_t
>
(),
grad_input
.
data
_ptr
<
scalar_t
>
(),
rois
.
contiguous
().
data
<
scalar_t
>
(),
rois
.
contiguous
().
data
_ptr
<
scalar_t
>
(),
n_stride
,
n_stride
,
c_stride
,
c_stride
,
h_stride
,
h_stride
,
...
...
torchvision/csrc/cuda/nms_cuda.cu
View file @
c6e41b5d
...
@@ -96,19 +96,19 @@ at::Tensor nms_cuda(const at::Tensor& dets,
...
@@ -96,19 +96,19 @@ at::Tensor nms_cuda(const at::Tensor& dets,
nms_kernel
<
scalar_t
><<<
blocks
,
threads
,
0
,
stream
>>>
(
nms_kernel
<
scalar_t
><<<
blocks
,
threads
,
0
,
stream
>>>
(
dets_num
,
dets_num
,
iou_threshold
,
iou_threshold
,
dets_sorted
.
data
<
scalar_t
>
(),
dets_sorted
.
data
_ptr
<
scalar_t
>
(),
(
unsigned
long
long
*
)
mask
.
data
<
int64_t
>
());
(
unsigned
long
long
*
)
mask
.
data
_ptr
<
int64_t
>
());
});
});
at
::
Tensor
mask_cpu
=
mask
.
to
(
at
::
kCPU
);
at
::
Tensor
mask_cpu
=
mask
.
to
(
at
::
kCPU
);
unsigned
long
long
*
mask_host
=
(
unsigned
long
long
*
)
mask_cpu
.
data
<
int64_t
>
();
unsigned
long
long
*
mask_host
=
(
unsigned
long
long
*
)
mask_cpu
.
data
_ptr
<
int64_t
>
();
std
::
vector
<
unsigned
long
long
>
remv
(
col_blocks
);
std
::
vector
<
unsigned
long
long
>
remv
(
col_blocks
);
memset
(
&
remv
[
0
],
0
,
sizeof
(
unsigned
long
long
)
*
col_blocks
);
memset
(
&
remv
[
0
],
0
,
sizeof
(
unsigned
long
long
)
*
col_blocks
);
at
::
Tensor
keep
=
at
::
Tensor
keep
=
at
::
empty
({
dets_num
},
dets
.
options
().
dtype
(
at
::
kLong
).
device
(
at
::
kCPU
));
at
::
empty
({
dets_num
},
dets
.
options
().
dtype
(
at
::
kLong
).
device
(
at
::
kCPU
));
int64_t
*
keep_out
=
keep
.
data
<
int64_t
>
();
int64_t
*
keep_out
=
keep
.
data
_ptr
<
int64_t
>
();
int
num_to_keep
=
0
;
int
num_to_keep
=
0
;
for
(
int
i
=
0
;
i
<
dets_num
;
i
++
)
{
for
(
int
i
=
0
;
i
<
dets_num
;
i
++
)
{
...
...
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