SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
|
The Catch2 test fixture used by all C++ unit tests. More...
#include <smaug_test.h>
The Catch2 test fixture used by all C++ unit tests.
This fixture encapsulates a Network and Workspace, and exposes a set of useful functions for writing unit tests, like filling Tensors with random data and verifying approximate equality of two Tensors.
Definition at line 43 of file smaug_test.h.
Public Member Functions | |
template<typename T > | |
void | allocateAllTensors (Operator *op) |
Allocates data storage for all Tensors in the Operator. More... | |
template<typename T > | |
void | createAndFillTensorsWithData (Operator *op, FillTensorDataFunc fillTensorDataFunc) |
Fills every input Tensor in the Operator with data by calling the provided FillTensorDataFunc. More... | |
template<typename DType > | |
void | verifyOutputs (Tensor *output, const std::vector< DType > &expected) |
Compares the contents of the given Tensor against an std::vector of data elements and asserts (REQUIRE) that the two are approximately pointwise equal. More... | |
template<typename DType > | |
void | verifyOutputs (Tensor *output, Tensor *expected) |
Compares the contents of the two given Tensors against each other and asserts (REQUIRE) that the two are approximately pointwise equal. More... | |
Network * | buildNetwork (const std::string &modelTopo, const std::string &modelParams) |
Tensor * | buildAndRunNetwork (const std::string &modelTopo, const std::string &modelParams) |
Network * | network () const |
Workspace * | workspace () const |
Protected Member Functions | |
std::string | resolvePath (const std::string &relPath) |
Resolves a SMAUG_HOME relative path to a particular resource (like a protobuf). | |
Protected Attributes | |
Network * | network_ |
Workspace * | workspace_ |
|
inline |
Allocates data storage for all Tensors in the Operator.
T | The data element type. |
op | The Operator. |
Definition at line 68 of file smaug_test.h.
|
inline |
Fills every input Tensor in the Operator with data by calling the provided FillTensorDataFunc.
T | The type of data stored in the Tensors. |
op | The Operator |
fillTensorDataFunc | A pointer to a function to auto-generate testing data for the Tensor. |
Definition at line 89 of file smaug_test.h.
|
inline |
Compares the contents of the given Tensor against an std::vector of data elements and asserts (REQUIRE) that the two are approximately pointwise equal.
Any region of the Tensor that would be ignored by its TensorIndexIterator (like alignment zero-padding) are not included in the pointwise comparison.
Definition at line 107 of file smaug_test.h.
|
inline |
Compares the contents of the two given Tensors against each other and asserts (REQUIRE) that the two are approximately pointwise equal.
Any region of the Tensor that would be ignored by its TensorIndexIterator (like alignment zero-padding) are not included in the pointwise comparison.
Definition at line 126 of file smaug_test.h.