forked from zhanghang1989/PyTorch-Encoding
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c05c2a5
commit a3c3d94
Showing
8 changed files
with
99 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
* Created by: Hang Zhang | ||
* ECE Department, Rutgers University | ||
* Email: zhang.hang@rutgers.edu | ||
* Copyright (c) 2017 | ||
* | ||
* This source code is licensed under the MIT-style license found in the | ||
* LICENSE file in the root directory of this source tree | ||
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
*/ | ||
#ifndef THC_GENERIC_FILE | ||
#define THC_GENERIC_FILE "generic/device_tensor.h" | ||
#else | ||
template <int Dim> | ||
THCDeviceTensor<float, Dim> devicetensor(THCState *state, THCTensor *t) { | ||
if (!t) { | ||
return THCDeviceTensor<float, Dim>(); | ||
} | ||
int inDim = THCTensor_(nDimension)(state, t); | ||
if (inDim == Dim) { | ||
return toDeviceTensor<float, Dim>(state, t); | ||
} | ||
// View in which the last dimensions are collapsed or expanded as needed | ||
THAssert(THCTensor_(isContiguous)(state, t)); | ||
int size[Dim]; | ||
for (int i = 0; i < Dim || i < inDim; ++i) { | ||
if (i < Dim && i < inDim) { | ||
size[i] = t->size[i]; | ||
} else if (i < Dim) { | ||
size[i] = 1; | ||
} else { | ||
size[Dim - 1] *= t->size[i]; | ||
} | ||
} | ||
return THCDeviceTensor<float, Dim>(THCTensor_(data)(state, t), size); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
mkdir -p encoding/build && cd encoding/build | ||
# compile and install | ||
cmake .. | ||
make install | ||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters