Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/doxygen.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1245,15 +1245,15 @@ HTML_TIMESTAMP = YES
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_DYNAMIC_MENUS = YES
HTML_DYNAMIC_MENUS = NO

# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
# page has loaded.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_DYNAMIC_SECTIONS = YES
HTML_DYNAMIC_SECTIONS = NO

# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
# shown in the various tree structured indices initially; the user can expand
Expand Down
13 changes: 13 additions & 0 deletions src/backend/cpu/Array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@ void evalMultiple(vector<Array<T> *> array_ptrs) {
vector<Param<T>> params;
if (getQueue().is_worker())
AF_ERROR("Array not evaluated", AF_ERR_INTERNAL);

// Check if all the arrays have the same dimension
auto it = std::adjacent_find(begin(array_ptrs), end(array_ptrs),
[](const Array<T> *l, const Array<T> *r) {
return l->dims() != r->dims();
});

// If they are not the same. eval individually
if (it != end(array_ptrs)) {
for (auto ptr : array_ptrs) { ptr->eval(); }
return;
}

for (Array<T> *array : array_ptrs) {
if (array->ready) continue;

Expand Down
12 changes: 12 additions & 0 deletions src/backend/cuda/Array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,18 @@ void evalMultiple(std::vector<Array<T> *> arrays) {
vector<Array<T> *> output_arrays;
vector<Node *> nodes;

// Check if all the arrays have the same dimension
auto it = std::adjacent_find(begin(arrays), end(arrays),
[](const Array<T> *l, const Array<T> *r) {
return l->dims() != r->dims();
});

// If they are not the same. eval individually
if (it != end(arrays)) {
for (auto ptr : arrays) { ptr->eval(); }
return;
}

for (Array<T> *array : arrays) {
if (array->isReady()) { continue; }

Expand Down
5 changes: 5 additions & 0 deletions src/backend/cuda/join.cu
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ Array<T> join(const int dim, const std::vector<Array<T>> &inputs) {
}
}

std::vector<Array<T> *> input_ptrs(inputs.size());
std::transform(
begin(inputs), end(inputs), begin(input_ptrs),
[](const Array<T> &input) { return const_cast<Array<T> *>(&input); });
evalMultiple(input_ptrs);
Array<T> out = createEmptyArray<T>(odims);

switch (n_arrays) {
Expand Down
12 changes: 12 additions & 0 deletions src/backend/opencl/Array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ void evalMultiple(vector<Array<T> *> arrays) {
vector<Array<T> *> output_arrays;
vector<Node *> nodes;

// Check if all the arrays have the same dimension
auto it = std::adjacent_find(begin(arrays), end(arrays),
[](const Array<T> *l, const Array<T> *r) {
return l->dims() != r->dims();
});

// If they are not the same. eval individually
if (it != end(arrays)) {
for (auto ptr : arrays) { ptr->eval(); }
return;
}

for (Array<T> *array : arrays) {
if (array->isReady()) { continue; }

Expand Down
6 changes: 6 additions & 0 deletions src/backend/opencl/join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ Array<T> join(const int dim, const std::vector<Array<T>> &inputs) {
}
}

std::vector<Array<T> *> input_ptrs(inputs.size());
std::transform(
begin(inputs), end(inputs), begin(input_ptrs),
[](const Array<T> &input) { return const_cast<Array<T> *>(&input); });
evalMultiple(input_ptrs);
std::vector<Param> inputParams(inputs.begin(), inputs.end());
Array<T> out = createEmptyArray<T>(odims);

switch (n_arrays) {
Expand Down
47 changes: 47 additions & 0 deletions test/join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
#include <af/dim4.hpp>
#include <af/index.h>
#include <af/traits.hpp>

#include <complex>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

Expand All @@ -26,6 +28,7 @@ using af::dim4;
using af::dtype_traits;
using af::join;
using af::randu;
using af::seq;
using af::sum;
using std::endl;
using std::string;
Expand Down Expand Up @@ -199,3 +202,47 @@ TEST(JoinMany1, CPP) {
array gold = join(dim, a0, join(dim, a1, join(dim, a2, a3)));
ASSERT_EQ(sum<float>(output - gold), 0);
}

TEST(Join, DifferentSizes) {
array a = seq(10);
array b = seq(11);
array c = seq(12);

array d = join(0, a, b, c);

vector<float> ha(10);
vector<float> hb(11);
vector<float> hc(12);

for (int i = 0; i < ha.size(); i++) { ha[i] = i; }
for (int i = 0; i < hb.size(); i++) { hb[i] = i; }
for (int i = 0; i < hc.size(); i++) { hc[i] = i; }
vector<float> hgold(10 + 11 + 12);
vector<float>::iterator it = copy(ha.begin(), ha.end(), hgold.begin());
it = copy(hb.begin(), hb.end(), it);
it = copy(hc.begin(), hc.end(), it);

ASSERT_VEC_ARRAY_EQ(hgold, dim4(10 + 11 + 12), d);
}

TEST(Join, SameSize) {
array a = seq(10);
array b = seq(10);
array c = seq(10);

array d = join(0, a, b, c);

vector<float> ha(10);
vector<float> hb(10);
vector<float> hc(10);

for (int i = 0; i < ha.size(); i++) { ha[i] = i; }
for (int i = 0; i < hb.size(); i++) { hb[i] = i; }
for (int i = 0; i < hc.size(); i++) { hc[i] = i; }
vector<float> hgold(10 + 10 + 10);
vector<float>::iterator it = copy(ha.begin(), ha.end(), hgold.begin());
it = copy(hb.begin(), hb.end(), it);
it = copy(hc.begin(), hc.end(), it);

ASSERT_VEC_ARRAY_EQ(hgold, dim4(10 + 10 + 10), d);
}