[Question]In what situations will af::copy() fail

Open
#3,638 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp

Research direction

The issue provides a TEST_CASE("af::copy()") using af::array, af::seq, af::span, and af::copy. Start by reproducing the supplied test and inspecting the af::copy API behavior; done requires a clear explanation of the situations in which af::copy() fails.

Written by the indexing model from the issue text.

Description

TEST_CASE("af::copy()") {
    double data[] = {1.0, 2.0, 3.0, 4.0, 5, 6, 7, 8,9,10,11,12,13,14,15,16,17,18};
    af::array a(2, 3, 3, data);
    af::array b(2, 3, 3, af::dtype::f64);

    af::array at = a(af::seq(0, 1), af::seq(0, 1), af::seq(0, 1));
    af::array bt = b(af::seq(0, 1), af::seq(0, 1), af::seq(0, 1));

    af::copy(bt, at, af::span);

    CHECK(b(0, 0, 0).scalar<double>() == 0.0);
    CHECK(b(1, 0, 0).scalar<double>() == 0.0);
    CHECK(b(0, 1, 0).scalar<double>() == 0.0);
    CHECK(b(1, 1, 0).scalar<double>() == 0.0);

    af::array at1 = a(af::seq(0, 1), af::seq(0, 0), af::seq(0, 0));
    af::array bt1 = b(af::seq(0, 1), af::seq(0, 0), af::seq(0, 0));

    af::copy(bt1, at1, af::span);

    CHECK(b(0, 0, 0).scalar<double>() == 1.0);
    CHECK(b(1, 0, 0).scalar<double>() == 2.0);
    CHECK(b(0, 1, 0).scalar<double>() == 0.0);
    CHECK(b(1, 1, 0).scalar<double>() == 0.0);
}
Dominant language
C++
Stars
4.9k
Forks
555
Avg merge
1h 24m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from arrayfire/arrayfire

All issues in arrayfire/arrayfire

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.