Skip to content

Add new LengthsSplit operator#10291

Closed
kurtisdavid wants to merge 1 commit intopytorch:masterfrom
kurtisdavid:export-D9013119
Closed

Add new LengthsSplit operator#10291
kurtisdavid wants to merge 1 commit intopytorch:masterfrom
kurtisdavid:export-D9013119

Conversation

@kurtisdavid
Copy link

Summary:
This new operator will do the following:

Given a LENGTHS vector and n_splits, output a "split" LENGTHS vector where:

  1. Each length in input vector is split into n_splits values (thus output vector should have LENGTHS.size(0) * n_splits elements)
  2. The new lengths in output should be evenly split, and if the length is not divisible by n_splits, then order new values in descending order. (e.g. n_splits = 3, length = 5 -> 2 2 1)
  3. If n_splits > some element in the array, its split elements will contain 0s. (e.g. n_splits = 3, length = 2 - > 1 1 0)

Differential Revision: D9013119

Summary:
Pull Request resolved: pytorch#10291

This new operator will do the following:

Given a LENGTHS vector and n_splits, output a "split" LENGTHS vector where:

1. Each length in input vector is split into n_splits values (thus output vector should have LENGTHS.size(0) * n_splits elements)
2. The new lengths in output should be evenly split, and if the length is not divisible by n_splits, then order new values in descending order. (e.g. n_splits = 3, length = 5 -> 2 2 1)
3. If n_splits > some element in the array, its split elements will contain 0s. (e.g. n_splits = 3, length = 2 - > 1 1 0)

Differential Revision: D9013119

fbshipit-source-id: 868caaaf0cf627980928e34e4859a38f20264ede
@bddppq
Copy link
Contributor

bddppq commented Aug 17, 2018

@pytorchbot retest this please


bool RunOnDevice() override {
const auto& L = Input(0);
CAFFE_ENFORCE(L.ndim() == 1, "Input `LENGTHS` should be a 1D vector.");

This comment was marked as off-topic.

const auto& L = Input(0);
CAFFE_ENFORCE(L.ndim() == 1, "Input `LENGTHS` should be a 1D vector.");

std::array<int32_t, 1> temp_params = {{n_splits_}};

This comment was marked as off-topic.

context_.template CopyItems<Context, CPUContext>(
input1.meta(),
1,
static_cast<const char*>(input1.raw_data()),

This comment was marked as off-topic.

np.array([1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1]))

@given(**hu.gcs_cpu_only)
def test_length_split_arg(self, gc, dc):

This comment was marked as off-topic.

Oscarlight pushed a commit to Oscarlight/pytorch that referenced this pull request Sep 9, 2018
Summary:
Pull Request resolved: pytorch#10974

Pull Request resolved: pytorch#10291

This new operator will do the following:

Given a LENGTHS vector and n_splits, output a "split" LENGTHS vector where:

1. Each length in input vector is split into n_splits values (thus output vector should have LENGTHS.size(0) * n_splits elements)
2. The new lengths in output should be evenly split, and if the length is not divisible by n_splits, then order new values in descending order. (e.g. n_splits = 3, length = 5 -> 2 2 1)
3. If n_splits > some element in the array, its split elements will contain 0s. (e.g. n_splits = 3, length = 2 - > 1 1 0)

Reviewed By: bddppq, chocjy

Differential Revision: D9013119

fbshipit-source-id: ad773dcaae813c253068a7cf7e774020627f0b13
PenghuiCheng pushed a commit to PenghuiCheng/pytorch that referenced this pull request Sep 11, 2018
Summary:
Pull Request resolved: pytorch#10974

Pull Request resolved: pytorch#10291

This new operator will do the following:

Given a LENGTHS vector and n_splits, output a "split" LENGTHS vector where:

1. Each length in input vector is split into n_splits values (thus output vector should have LENGTHS.size(0) * n_splits elements)
2. The new lengths in output should be evenly split, and if the length is not divisible by n_splits, then order new values in descending order. (e.g. n_splits = 3, length = 5 -> 2 2 1)
3. If n_splits > some element in the array, its split elements will contain 0s. (e.g. n_splits = 3, length = 2 - > 1 1 0)

Reviewed By: bddppq, chocjy

Differential Revision: D9013119

fbshipit-source-id: 82bf3371ec08c41fc3379177f0007afc142e0d84
@ezyang ezyang added the merged label Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants