SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
smaug::SmaugTest Class Reference

The Catch2 test fixture used by all C++ unit tests. More...

#include <smaug_test.h>

Detailed Description

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...
 
NetworkbuildNetwork (const std::string &modelTopo, const std::string &modelParams)
 
TensorbuildAndRunNetwork (const std::string &modelTopo, const std::string &modelParams)
 
Networknetwork () const
 
Workspaceworkspace () 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

Networknetwork_
 
Workspaceworkspace_
 

Member Function Documentation

◆ allocateAllTensors()

template<typename T >
void smaug::SmaugTest::allocateAllTensors ( Operator op)
inline

Allocates data storage for all Tensors in the Operator.

Template Parameters
TThe data element type.
Parameters
opThe Operator.

Definition at line 68 of file smaug_test.h.

◆ createAndFillTensorsWithData()

template<typename T >
void smaug::SmaugTest::createAndFillTensorsWithData ( Operator op,
FillTensorDataFunc  fillTensorDataFunc 
)
inline

Fills every input Tensor in the Operator with data by calling the provided FillTensorDataFunc.

Template Parameters
TThe type of data stored in the Tensors.
Parameters
opThe Operator
fillTensorDataFuncA pointer to a function to auto-generate testing data for the Tensor.

Definition at line 89 of file smaug_test.h.

◆ verifyOutputs() [1/2]

template<typename DType >
void smaug::SmaugTest::verifyOutputs ( Tensor output,
const std::vector< DType > &  expected 
)
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.

◆ verifyOutputs() [2/2]

template<typename DType >
void smaug::SmaugTest::verifyOutputs ( Tensor output,
Tensor expected 
)
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.


The documentation for this class was generated from the following file: