Caten Documentation

  • Home
  • Quickstart
  • Development
  • API Reference
    • caten/air
    • caten/aasm
    • caten/codegen
    • caten/api
      • Overview
      • Tensor
      • Func
      • Module
      • Model
      • Initializers
      • ShapeTracker
      • Facet API
      • StateDict
    • caten/nn
      • Activation
      • Convolution
      • Criterion
      • Embedding
      • Linear
      • Normalization
      • Padding
      • Pooling
      • Encoding
      • Optimizers
  • Ready to use packages
    • Overview
    • caten/apps.gpt2
  • External Packages
    • caten/gguf
    • caten/oonx
    • caten/llm
In this article
  • Padding
    • [class] Padding
    • [function] !padding
    • [function] !padding2d

Padding

  1. Caten Documentation
  2. API Reference
  3. caten/nn
  4. Padding
|
  • Share via

  •  Edit this article

Padding

[class] Padding

The Func Padding pads the input_tensor with the specified padding. The argument is given in the following format.

(output_tensor, input_tensor, *index_components, *padding_starts, *padding_ends)
where each (length index_components), (length padding_starts), and (length padding_ends) == ndim(input_tensor) == ndim(output_tensor).

With JIT=1, everything is expected to be fused in a single EXPR like:

out = where(start_0 < index_components[0] < end_0 and start_1 < index_components[1] < end_1 and ..., input_tensor[i=i'-start_0, j=j'_start_1, ...], value)

[function] !padding

(!padding x padding &key (value 0.0))
Pads the tensor x with the specified padding and value.

Padding is specified as: ((pad_0_1 pad_0_2) (pad_1_0 pad_1_0) ...). If T is provided instead of (pad_0_0 pad_0_1), that means no padding is applied to the axis. (that is, T = (0 0))

Each start_0 and pad_0 is expected as a positive integer (caten will not check this!), or a scalar int32/int64 tensor.

[function] !padding2d

(!padding2d x padding &key (value 0.0))
Pads the last two dimension of the tensor x with the specified padding and value..

padding is specified as: (padding_left padding_right padding_top padding_bottom).

Search
Enter a keyword to search.