mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
- `Mangle::ASTMangler::mangleAutoDiffDerivativeFunction()` and `Mangle::ASTMangler::mangleAutoDiffLinearMap()` accept original function declarations and return a mangled name for a derivative function or linear map. This is called during SILGen and TBDGen. - `Mangle::DifferentiationMangler` handles differentiation function mangling in the differentiation transform. This part is necessary because we need to perform demangling on the original function and remangle it as part of a differentiation function mangling tree in order to get the correct substitutions in the mangled derivative generic signature. A mangled differentiation function name includes: - The original function. - The differentiation function kind. - The parameter indices for differentiation. - The result indices for differentiation. - The derivative generic signature.
57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
//===--- JVPCloner.h - JVP function generation ----------------*- C++ -*---===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2019 - 2020 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines a helper class for generating JVP functions for automatic
|
|
// differentiation.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_SILOPTIMIZER_UTILS_DIFFERENTIATION_JVPCLONER_H
|
|
#define SWIFT_SILOPTIMIZER_UTILS_DIFFERENTIATION_JVPCLONER_H
|
|
|
|
#include "swift/SILOptimizer/Differentiation/DifferentiationInvoker.h"
|
|
|
|
namespace swift {
|
|
|
|
class SILFunction;
|
|
class SILDifferentiabilityWitness;
|
|
|
|
namespace autodiff {
|
|
|
|
class ADContext;
|
|
|
|
/// A helper class for generating JVP functions.
|
|
class JVPCloner final {
|
|
class Implementation;
|
|
Implementation &impl;
|
|
|
|
public:
|
|
/// Creates a JVP cloner.
|
|
///
|
|
/// The parent JVP cloner stores the original function and an empty
|
|
/// to-be-generated pullback function.
|
|
explicit JVPCloner(ADContext &context, SILDifferentiabilityWitness *witness,
|
|
SILFunction *jvp, DifferentiationInvoker invoker);
|
|
~JVPCloner();
|
|
|
|
/// Performs JVP generation on the empty JVP function. Returns true if any
|
|
/// error occurs.
|
|
bool run();
|
|
|
|
SILFunction &getJVP() const;
|
|
};
|
|
|
|
} // end namespace autodiff
|
|
} // end namespace swift
|
|
|
|
#endif // SWIFT_SILOPTIMIZER_UTILS_DIFFERENTIATION_JVPCLONER_H
|