FreeTensor
Loading...
Searching...
No Matches
Public Member Functions | List of all members
freetensor::Derivative::LazyPartialDerivative Class Reference

#include <derivative.h>

Public Member Functions

 LazyPartialDerivative ()
 
 LazyPartialDerivative (const SymbolTableData &symbolTable, const Expr &mathExpr, const ID &rootStmtID, const std::optional< InvertFromStore > &invertFromStore=std::nullopt)
 
void merge (const LazyPartialDerivative &other)
 += another partial derivative
 
const ExprmathExpr () const
 
bool usingStore ()
 True if using y for y = f(x)'s derivative.
 
const std::unordered_set< std::string > & reads ()
 
Expr replaceExpr (const std::unordered_map< ID, std::string > &intermediatesMap, const std::unordered_map< StmtOrExprID, Expr > &versions, const Expr &expr)
 
Expr genReplaced (const std::unordered_map< ID, std::string > &intermediatesMap, const std::unordered_map< StmtOrExprID, Expr > &versions)
 

Detailed Description

Lazy partial derivative dy/dx_i

Constructor & Destructor Documentation

◆ LazyPartialDerivative() [1/2]

freetensor::Derivative::LazyPartialDerivative::LazyPartialDerivative ( )
inline

◆ LazyPartialDerivative() [2/2]

freetensor::Derivative::LazyPartialDerivative::LazyPartialDerivative ( const SymbolTableData symbolTable,
const Expr mathExpr,
const ID rootStmtID,
const std::optional< InvertFromStore > &  invertFromStore = std::nullopt 
)
inline

Member Function Documentation

◆ genReplaced()

Expr freetensor::Derivative::LazyPartialDerivative::genReplaced ( const std::unordered_map< ID, std::string > &  intermediatesMap,
const std::unordered_map< StmtOrExprID, Expr > &  versions 
)
inline

Generate finaly derivative expression, where all Load loads from actual tape or recomputation

◆ mathExpr()

const Expr & freetensor::Derivative::LazyPartialDerivative::mathExpr ( ) const
inline

Raw derivative expression. Loads in the statements loads forward variables named in the original program, not the final backward pass

◆ merge()

void freetensor::Derivative::LazyPartialDerivative::merge ( const LazyPartialDerivative other)
inline

+= another partial derivative

◆ reads()

const std::unordered_set< std::string > & freetensor::Derivative::LazyPartialDerivative::reads ( )

All variables needed to compute the derivative, including variables for tensor indexing, NOT including the y in usingStore. Please note that since grad(x) = derivative * grad(y), this function does not include variable used in grad(x) or grad(y)'s indices.

◆ replaceExpr()

Expr freetensor::Derivative::LazyPartialDerivative::replaceExpr ( const std::unordered_map< ID, std::string > &  intermediatesMap,
const std::unordered_map< StmtOrExprID, Expr > &  versions,
const Expr expr 
)

Replace any expression in the same context with this LazyPartialDerivative to use taped or recomputed variables

◆ usingStore()

bool freetensor::Derivative::LazyPartialDerivative::usingStore ( )

True if using y for y = f(x)'s derivative.


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