torch-linear-assignment 0.0.2__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {torch_linear_assignment-0.0.2/torch_linear_assignment.egg-info → torch_linear_assignment-0.0.3}/PKG-INFO +8 -2
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/setup.py +1 -1
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/src/torch_linear_assignment_cuda_kernel.cu +30 -23
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3/torch_linear_assignment.egg-info}/PKG-INFO +8 -2
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/LICENSE +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/MANIFEST.in +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/README.md +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/pyproject.toml +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/requirements.txt +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/setup.cfg +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/src/torch_linear_assignment.cpp +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/src/torch_linear_assignment_cuda.cpp +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/torch_linear_assignment/__init__.py +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/torch_linear_assignment/assignment.py +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/torch_linear_assignment.egg-info/SOURCES.txt +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/torch_linear_assignment.egg-info/dependency_links.txt +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/torch_linear_assignment.egg-info/requires.txt +0 -0
- {torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/torch_linear_assignment.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: torch-linear-assignment
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: Batched linear assignment with PyTorch and CUDA.
|
|
5
5
|
Author: Ivan Karpukhin
|
|
6
6
|
Author-email: karpuhini@yandex.ru
|
|
@@ -8,6 +8,12 @@ Description-Content-Type: text/markdown
|
|
|
8
8
|
License-File: LICENSE
|
|
9
9
|
Requires-Dist: torch>=1.12.0
|
|
10
10
|
Requires-Dist: scipy>=1.6.0
|
|
11
|
+
Dynamic: author
|
|
12
|
+
Dynamic: author-email
|
|
13
|
+
Dynamic: description
|
|
14
|
+
Dynamic: description-content-type
|
|
15
|
+
Dynamic: requires-dist
|
|
16
|
+
Dynamic: summary
|
|
11
17
|
|
|
12
18
|
# Batch linear assignment for PyTorch
|
|
13
19
|
[](https://badge.fury.io/py/torch-linear-assignment)
|
|
@@ -48,7 +48,7 @@ with open("README.md") as fp:
|
|
|
48
48
|
if __name__ == '__main__':
|
|
49
49
|
setuptools.setup(
|
|
50
50
|
name="torch-linear-assignment",
|
|
51
|
-
version="0.0.
|
|
51
|
+
version="0.0.3",
|
|
52
52
|
author="Ivan Karpukhin",
|
|
53
53
|
author_email="karpuhini@yandex.ru",
|
|
54
54
|
description="Batched linear assignment with PyTorch and CUDA.",
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
#include <cuda.h>
|
|
11
11
|
#include <cuda_runtime.h>
|
|
12
|
-
#include <thrust/device_vector.h>
|
|
13
|
-
#include <thrust/fill.h>
|
|
14
12
|
|
|
15
13
|
#include <torch/extension.h>
|
|
16
14
|
#include <ATen/cuda/CUDAContext.h>
|
|
@@ -203,8 +201,10 @@ void solve_cuda_kernel_batch(int bs, int nr, int nc,
|
|
|
203
201
|
}
|
|
204
202
|
|
|
205
203
|
|
|
204
|
+
|
|
206
205
|
template <typename scalar_t>
|
|
207
|
-
void solve_cuda_batch(
|
|
206
|
+
void solve_cuda_batch(c10::ScalarType scalar_type,
|
|
207
|
+
int device_index,
|
|
208
208
|
int bs, int nr, int nc,
|
|
209
209
|
scalar_t *cost, int *col4row, int *row4col) {
|
|
210
210
|
cudaSetDevice(device_index);
|
|
@@ -212,32 +212,38 @@ void solve_cuda_batch(int device_index,
|
|
|
212
212
|
TORCH_CHECK(std::numeric_limits<scalar_t>::has_infinity, "Data type doesn't have infinity.");
|
|
213
213
|
auto infinity = std::numeric_limits<scalar_t>::infinity();
|
|
214
214
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
215
|
+
auto int_opt = torch::TensorOptions()
|
|
216
|
+
.dtype(torch::kInt)
|
|
217
|
+
.device(torch::kCUDA, device_index);
|
|
218
|
+
auto scalar_t_opt = torch::TensorOptions()
|
|
219
|
+
.dtype(scalar_type)
|
|
220
|
+
.device(torch::kCUDA, device_index);
|
|
221
|
+
auto uint8_opt = torch::TensorOptions()
|
|
222
|
+
.dtype(torch::kUInt8)
|
|
223
|
+
.device(torch::kCUDA, device_index);
|
|
224
|
+
|
|
225
|
+
torch::Tensor u = torch::zeros({bs * nr}, scalar_t_opt);
|
|
226
|
+
torch::Tensor v = torch::zeros({bs * nc}, scalar_t_opt);
|
|
227
|
+
torch::Tensor shortestPathCosts = torch::empty({bs * nc}, scalar_t_opt);
|
|
228
|
+
torch::Tensor path = torch::full({bs * nc}, -1, int_opt);
|
|
229
|
+
torch::Tensor SR = torch::empty({bs * nr}, uint8_opt);
|
|
230
|
+
torch::Tensor SC = torch::empty({bs * nc}, uint8_opt);
|
|
231
|
+
torch::Tensor remaining = torch::empty({bs * nc}, int_opt);
|
|
232
|
+
|
|
233
|
+
static const int blockSize = SMPCores(device_index);
|
|
228
234
|
int gridSize = (bs + blockSize - 1) / blockSize;
|
|
229
235
|
at::cuda::CUDAStream stream = at::cuda::getCurrentCUDAStream(device_index);
|
|
230
236
|
solve_cuda_kernel_batch<<<gridSize, blockSize, 0, stream.stream()>>>(
|
|
231
237
|
bs, nr, nc,
|
|
232
238
|
cost,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
239
|
+
u.data<scalar_t>(),
|
|
240
|
+
v.data<scalar_t>(),
|
|
241
|
+
shortestPathCosts.data<scalar_t>(),
|
|
242
|
+
path.data<int>(),
|
|
237
243
|
col4row, row4col,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
244
|
+
SR.data<uint8_t>(),
|
|
245
|
+
SC.data<uint8_t>(),
|
|
246
|
+
remaining.data<int>(),
|
|
241
247
|
infinity);
|
|
242
248
|
cudaError_t err = cudaGetLastError();
|
|
243
249
|
if (err != cudaSuccess) {
|
|
@@ -265,6 +271,7 @@ std::vector<torch::Tensor> batch_linear_assignment_cuda(torch::Tensor cost) {
|
|
|
265
271
|
|
|
266
272
|
AT_DISPATCH_FLOATING_TYPES(cost.scalar_type(), "solve_cuda_batch", [&] {
|
|
267
273
|
solve_cuda_batch<scalar_t>(
|
|
274
|
+
cost.scalar_type(),
|
|
268
275
|
device.index(),
|
|
269
276
|
sizes[0], sizes[1], sizes[2],
|
|
270
277
|
cost.data<scalar_t>(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: torch-linear-assignment
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: Batched linear assignment with PyTorch and CUDA.
|
|
5
5
|
Author: Ivan Karpukhin
|
|
6
6
|
Author-email: karpuhini@yandex.ru
|
|
@@ -8,6 +8,12 @@ Description-Content-Type: text/markdown
|
|
|
8
8
|
License-File: LICENSE
|
|
9
9
|
Requires-Dist: torch>=1.12.0
|
|
10
10
|
Requires-Dist: scipy>=1.6.0
|
|
11
|
+
Dynamic: author
|
|
12
|
+
Dynamic: author-email
|
|
13
|
+
Dynamic: description
|
|
14
|
+
Dynamic: description-content-type
|
|
15
|
+
Dynamic: requires-dist
|
|
16
|
+
Dynamic: summary
|
|
11
17
|
|
|
12
18
|
# Batch linear assignment for PyTorch
|
|
13
19
|
[](https://badge.fury.io/py/torch-linear-assignment)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/src/torch_linear_assignment.cpp
RENAMED
|
File without changes
|
{torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/src/torch_linear_assignment_cuda.cpp
RENAMED
|
File without changes
|
{torch_linear_assignment-0.0.2 → torch_linear_assignment-0.0.3}/torch_linear_assignment/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|