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

Fixes for the c++ Simple and Extended examples in readme #108

Merged
merged 2 commits into from
Jan 4, 2021
Merged
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
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,17 @@ int main() {

// 3. Run multiplication operation synchronously
mgr.evalOpDefault<kp::OpMult>(
{ tensorInA, tensorInB, tensorOut })
{ tensorInA, tensorInB, tensorOut });

// 4. Map results back from GPU memory to print the results
mgr.evalOpDefault<kp::OpTensorSyncLocal>({ tensorInA, tensorInB, tensorOut })
mgr.evalOpDefault<kp::OpTensorSyncLocal>({ tensorInA, tensorInB, tensorOut });

// Prints the output which is Output: { 2, 4, 6 }
std::cout << fmt::format("Output: {}",
tensorOut.data()) << std::endl;
std::cout << "Output: { ";
for (const float& elem : tensorOut->data()) {
std::cout << elem << " ";
}
std::cout << "}" << std::endl;
}
```

Expand Down Expand Up @@ -157,9 +160,9 @@ int main() {
sq->begin();

// 5.2. Record batch commands
sq->record<kp::OpTensorSyncLocal({ tensorInA });
sq->record<kp::OpTensorSyncLocal({ tensorInB });
sq->record<kp::OpTensorSyncLocal({ tensorOut });
sq->record<kp::OpTensorSyncLocal>({ tensorInA });
sq->record<kp::OpTensorSyncLocal>({ tensorInB });
sq->record<kp::OpTensorSyncLocal>({ tensorOut });

// 5.3. Explicitly stop recording batch commands
sq->end();
Expand All @@ -168,8 +171,11 @@ int main() {
sq->eval();

// Prints the output which is Output: { 2, 4, 6 }
std::cout << fmt::format("Output: {}",
tensorOut.data()) << std::endl;
std::cout << "Output: { ";
for (const float& elem : tensorOut->data()) {
std::cout << elem << " ";
}
std::cout << "}" << std::endl;
}
```

Expand Down