---
title: "GradResult: interface in IR, TypeShade API reference"
description: "GradResult, an interface in IR. What grad returns: the module with the derivative function added, and its name."
url: https://typeshade.dev/api/gradresult/
language: en
---

# `GradResult`

Interface in IR

What grad returns: the module with the derivative function added, and its name.

`import type { GradResult } from 'typeshade'`

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
interface GradResult {
  readonly module: ModuleDecl;
  readonly name: string;
  readonly adjoints?: Readonly<Record<string, string>>;
  readonly tapeBytes?: number;
}
```

## Instance properties

**`module` read only `ModuleDecl`**

The input module plus the derivative function and the helpers it calls.

**`name` read only `string`**

The name of the derivative function in [`GradResult.module`](https://typeshade.dev/api/gradresult/).

**`adjoints` optional read only `Readonly<Record<string, string>>`**

Reverse mode only: for each name of `wrt`, the field of the returned struct that holds its adjoint.

**`tapeBytes` optional read only `number`**

Reverse mode only: the bytes of function memory the derivative’s tape takes in one invocation, its tape slots, branch records, loop counters and checkpoint slots, with the deepest chain of helpers it calls. No other memory is allocated for it.

## See also

- [`grad`](https://typeshade.dev/api/grad/)

## Source

[`src/core/passes/grad.ts`, line 41](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/grad.ts#L41), at commit af54ddad5
