Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android example throws runtime error. #77

Closed
tyler274 opened this issue Oct 20, 2020 · 5 comments · Fixed by #78
Closed

Android example throws runtime error. #77

tyler274 opened this issue Oct 20, 2020 · 5 comments · Fixed by #78

Comments

@tyler274
Copy link

tyler274 commented Oct 20, 2020

in void OpTensorSyncDevice::init()

for (std::shared_ptr<Tensor> tensor : this->mTensors) {
        if (!tensor->isInit()) {
            throw std::runtime_error("Kompute OpTensorSyncDevice: Tensor param "
                                     "has not been initialized");
        }

coming from void KomputeModelML::train

sq->record<kp::OpTensorSyncDevice>({ wIn, bIn });

in the app's code.

@axsaucedo
Copy link
Member

axsaucedo commented Oct 20, 2020

Thank you for reporting this @tyler274 ! This is due to a change that was added this weekend to support asynchronous and parallel operations, namely #75 and #73.

The fix for this is simple, and you have two options:

  1. Running the example against release 0.3.2 (Which means just checking out that branch)
  2. Add the same changes that were added in 74 Fixing manager default sequence creation #75 to the logistic regression test (which uses the same code)

For option #2, you will need to run the tensor creation on a separate sequence.

Namely, you have to change this part:

        if (std::shared_ptr<kp::Sequence> sq =
                    mgr.getOrCreateManagedSequence("createTensors").lock()) {

            sq->begin();

            sq->record<kp::OpTensorCreate>(params);

            sq->end();
            sq->eval();

            // Record op algo base
            sq->begin();

            sq->record<kp::OpTensorSyncDevice>({ wIn, bIn });

To this:

        std::shared_ptr<kp::Sequence> sqTensor =
              mgr.createManagedSequence().lock();

        sqTensor->begin();
        sqTensor->record<kp::OpTensorCreate>(params);
        sqTensor->end();
        sqTensor->eval();

        std::shared_ptr<kp::Sequence> sq = mgr.createManagedSequence().lock();

        sq->begin();

        sq->record<kp::OpTensorCreate>(params);

        sq->end();
        sq->eval();

        // Record op algo base
        sq->begin();

        sq->record<kp::OpTensorSyncDevice>({ wIn, bIn });

This is something you can find in the test/TestLogisticRegression.cpp file.

For now, I recommend you to go for option 1 - I will update the examples now so they work with the recent 0.4.0 release.

@axsaucedo
Copy link
Member

axsaucedo commented Oct 20, 2020

@tyler274 this now has been fixed in master, if you pull the latest you should be able to build - I just tested it with Android studio as well:

I'll re-open issue to confirm it has been fixed on your side.

@axsaucedo axsaucedo reopened this Oct 20, 2020
@tyler274
Copy link
Author

tyler274 commented Oct 20, 2020 via email

@tyler274
Copy link
Author

Works on master, thanks!

@axsaucedo
Copy link
Member

Great - thanks for confirming @tyler274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants