-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Tutorial Documentation touch-up #155
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
*** | ||
C++ | ||
*** | ||
|
||
|
||
In this section, examples are presented using the SmartRedis C++ | ||
API to interact with the RedisAI tensor, model, and script | ||
data types. Additionally, an example of utilizing the | ||
SmartRedis ``DataSet`` API is also provided. | ||
|
||
|
||
|
||
.. note:: | ||
The C++ API examples rely on the ``SSDB`` environment | ||
variable being set to the address and port of the Redis database. | ||
|
||
|
||
.. note:: | ||
The C++ API examples are written | ||
to connect to a clustered database or clustered SmartSim Orchestrator. | ||
Update the ``Client`` constructor ``cluster`` flag to `false` | ||
to connect to a single shard (single compute host) database. | ||
|
||
|
||
|
||
|
||
Tensors | ||
======= | ||
|
||
The following example shows how to send a receive a tensor using the | ||
SmartRedis C++ client API. | ||
|
||
.. literalinclude:: ../smartredis/examples/serial/cpp/smartredis_put_get_3D.cpp | ||
:linenos: | ||
:language: C++ | ||
|
||
DataSets | ||
======== | ||
|
||
The C++ client can store and retrieve tensors and metadata in datasets. | ||
For further information about datasets, please refer to the :ref:`Dataset | ||
section of the Data Structures documentation page <data_structures_dataset>`. | ||
|
||
The code below shows how to store and retrieve tensors and metadata | ||
which belong to a ``DataSet``. | ||
|
||
.. literalinclude:: ../smartredis/examples/serial/cpp/smartredis_dataset.cpp | ||
:linenos: | ||
:language: C++ | ||
|
||
.. _SR CPP Models: | ||
|
||
|
||
Models | ||
====== | ||
|
||
The following example shows how to store, and use a DL model | ||
in the database with the C++ Client. The model is stored as a file | ||
in the ``../../../common/mnist_data/`` path relative to the | ||
compiled executable. Note that this example also sets and | ||
executes a preprocessing script. | ||
|
||
.. literalinclude:: ../smartredis/examples/serial/cpp/smartredis_model.cpp | ||
:linenos: | ||
:language: C++ | ||
|
||
.. _SR CPP Scripts: | ||
|
||
Scripts | ||
======= | ||
|
||
The example in :ref:`SR CPP Models` shows how to store, and use a PyTorch script | ||
in the database with the C++ Client. The script is stored a file | ||
in the ``../../../common/mnist_data/`` path relative to the | ||
compiled executable. Note that this example also sets and | ||
executes a PyTorch model. | ||
|
||
.. _SR CPP Parallel MPI: | ||
|
||
Parallel (MPI) execution | ||
======================== | ||
|
||
In this example, the example shown in :ref:`SR CPP Models` and | ||
:ref:`SR CPP Scripts` is adapted to run in parallel using MPI. | ||
This example has the same functionality, however, | ||
it shows how keys can be prefixed to prevent key | ||
collisions across MPI ranks. Note that only one | ||
model and script are set, which is shared across | ||
all ranks. | ||
|
||
For completeness, the pre-processing script | ||
source code is also shown. | ||
|
||
**C++ program** | ||
|
||
.. literalinclude:: ../smartredis/examples/parallel/cpp/smartredis_mnist.cpp | ||
:linenos: | ||
:language: C++ | ||
|
||
**Python Pre-Processing** | ||
|
||
.. literalinclude:: ../smartredis/examples/common/mnist_data/data_processing_script.txt | ||
:linenos: | ||
:language: Python | ||
:lines: 15-20 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"stored a file" -> "stored as a file"