Package-level declarations

Types

Link copied to clipboard
class AvgPool2d<T : DType, V>(val kernelSize: Pair<Int, Int>, val stride: Pair<Int, Int> = kernelSize, val padding: Pair<Int, Int> = 0 to 0, val countIncludePad: Boolean = true, val name: String = "AvgPool2d") : Module<T, V>

2D Average Pooling layer that applies an average pooling operation over 2D input.

Link copied to clipboard
class Conv1d<T : DType, V>(val inChannels: Int, val outChannels: Int, val kernelSize: Int, val stride: Int = 1, val padding: Int = 0, val dilation: Int = 1, val groups: Int = 1, val bias: Boolean = true, val name: String = "Conv1d", initWeights: Tensor<T, V>, initBias: Tensor<T, V>? = null, val trainable: Boolean = true) : Module<T, V> , ModuleParameters<T, V>

1D Convolutional layer that applies a convolution operation over 1D input.

Link copied to clipboard
class Conv2d<T : DType, V> @JvmOverloads constructor(val inChannels: Int, val outChannels: Int, val kernelSize: Pair<Int, Int>, val stride: Pair<Int, Int> = 1 to 1, val padding: Pair<Int, Int> = 0 to 0, val dilation: Pair<Int, Int> = 1 to 1, val groups: Int = 1, val bias: Boolean = true, val name: String = "Conv2d", initWeights: Tensor<T, V>, initBias: Tensor<T, V>? = null, val trainable: Boolean = true) : Module<T, V> , ModuleParameters<T, V>

2D Convolutional layer that applies a convolution operation over 2D input.

Link copied to clipboard
class Conv3d<T : DType, V>(val inChannels: Int, val outChannels: Int, val kernelSize: Triple<Int, Int, Int>, val stride: Triple<Int, Int, Int> = Triple(1, 1, 1), val padding: Triple<Int, Int, Int> = Triple(0, 0, 0), val dilation: Triple<Int, Int, Int> = Triple(1, 1, 1), val groups: Int = 1, val bias: Boolean = true, val name: String = "Conv3d", initWeights: Tensor<T, V>, initBias: Tensor<T, V>? = null, val trainable: Boolean = true) : Module<T, V> , ModuleParameters<T, V>

3D Convolutional layer that applies a convolution operation over 3D input.

Link copied to clipboard
data class ConversionStats(var totalForwardCalls: Long = 0, var inputConversions: Long = 0, var outputConversions: Long = 0, var conversionErrors: Long = 0, var cacheHits: Long = 0, var cacheClears: Long = 0)

Statistics class for tracking mixed precision conversion performance.

Link copied to clipboard
class DefaultNeuralNetworkExecutionContext(val phase: Phase = sk.ainet.context.Phase.EVAL) : NeuralNetworkExecutionContext
Link copied to clipboard
class DepthwiseSeparableConv2d<T : DType, V>(val inChannels: Int, val outChannels: Int, val kernelSize: Pair<Int, Int>, val stride: Pair<Int, Int> = 1 to 1, val padding: Pair<Int, Int> = 0 to 0, val dilation: Pair<Int, Int> = 1 to 1, val bias: Boolean = true, val name: String = "DepthwiseSeparableConv2d", initDepthwiseWeights: Tensor<T, V>, initPointwiseWeights: Tensor<T, V>, initDepthwiseBias: Tensor<T, V>? = null, initPointwiseBias: Tensor<T, V>? = null) : Module<T, V> , ModuleParameters<T, V>

Depthwise Separable Convolution layer.

Link copied to clipboard
class DilatedConv2d<T : DType, V>(val inChannels: Int, val outChannels: Int, val kernelSize: Pair<Int, Int>, val dilation: Pair<Int, Int>, val stride: Pair<Int, Int> = 1 to 1, val padding: Pair<Int, Int> = 0 to 0, val groups: Int = 1, val bias: Boolean = true, val name: String = "DilatedConv2d", initWeights: Tensor<T, V>, initBias: Tensor<T, V>? = null) : Module<T, V> , ModuleParameters<T, V>

Dilated (Atrous) Convolution layer.

Link copied to clipboard
data class DilatedConvInfo(val dilation: Pair<Int, Int>, val kernelSize: Pair<Int, Int>, val effectiveKernelSize: Pair<Int, Int>, val receptiveFieldSize: Pair<Int, Int>, val receptiveFieldExpansion: Double, val parameterCount: Long, val isStandard: Boolean)

Data class containing information about dilated convolution configuration.

Link copied to clipboard
abstract class DualModule<InT : DType, OutT : DType, V> : ModuleNode

Dual-typed module for dtype-transforming or index-consuming ops. InT is the input dtype, OutT is the output dtype. V is the value buffer backend type.

Link copied to clipboard
class Flatten<T : DType, V>(startDim: Int = 1, endDim: Int = -1, val name: String = "Flatten") : Module<T, V>

A simple layer that flattens an input tensor into a 1D tensor. This layer has no parameters and simply reshapes the input.

Link copied to clipboard
data class FuncInput(val name: String, val dimensions: IntArray = intArrayOf())

Lightweight description of an expected input. Dimensions are optional metadata.

Link copied to clipboard
class Functional<T : DType, V>

Minimal multi-input functional wrapper to express a computation as a single callable model.

Link copied to clipboard
class GroupedConv2d<T : DType, V>(val inChannels: Int, val outChannels: Int, val kernelSize: Pair<Int, Int>, val groups: Int, val stride: Pair<Int, Int> = 1 to 1, val padding: Pair<Int, Int> = 0 to 0, val dilation: Pair<Int, Int> = 1 to 1, val bias: Boolean = true, val name: String = "GroupedConv2d", initWeights: Tensor<T, V>, initBias: Tensor<T, V>? = null) : Module<T, V> , ModuleParameters<T, V>

Grouped Convolution layer.

Link copied to clipboard
data class GroupedConvInfo(val groups: Int, val inputChannelsPerGroup: Int, val outputChannelsPerGroup: Int, val parameterCount: Long, val parameterReduction: Double, val isDepthwise: Boolean, val isStandard: Boolean)

Data class containing information about grouped convolution configuration.

Link copied to clipboard
class Input<T : DType, V>(val name: String = "Input", val requiresGrad: Boolean = false) : Module<T, V>
Link copied to clipboard
abstract class InternalMixedPrecisionModule<TIO : DType, TInternal : DType, V>(ioType: TIO, internalType: TInternal, conversionOps: MixedPrecisionTensorOps<V>) : Module<TIO, V>

Specialized mixed precision module for cases where input and output types are the same but internal computation uses a different precision.

Link copied to clipboard
class Linear<T : DType, V> @JvmOverloads constructor(inFeatures: Int, outFeatures: Int, val name: String = "Linear", initWeights: Tensor<T, V>, initBias: Tensor<T, V>, val trainable: Boolean = true) : Module<T, V> , ModuleParameters<T, V>

Linear layer (a.k.a. fully connected dense layer). This layer applies a linear transformation to the input data. The weights and biases are learned during training.

Link copied to clipboard
class MaxPool2d<T : DType, V> @JvmOverloads constructor(val kernelSize: Pair<Int, Int>, val stride: Pair<Int, Int> = kernelSize, val padding: Pair<Int, Int> = 0 to 0, val name: String = "MaxPool2d") : Module<T, V>

2D Max Pooling layer that applies a max pooling operation over 2D input.

Link copied to clipboard
class MixedPrecisionException(message: String, cause: Throwable? = null) : RuntimeException

Exception thrown when mixed precision operations fail.

Link copied to clipboard
abstract class MixedPrecisionModule<TInput : DType, TOutput : DType, V>(inputType: TInput, outputType: TOutput, conversionOps: MixedPrecisionTensorOps<V>) : Module<TInput, V>

Abstract base class for modules that support mixed-precision operations. This class handles automatic type conversions between different precision types, enabling seamless integration of layers with different precision requirements.

Link copied to clipboard
abstract class Module<T : DType, V> : ModuleNode
Link copied to clipboard

Context for the DSL to define the data type and operations.

Link copied to clipboard
class TransposedConv2d<T : DType, V>(val inChannels: Int, val outChannels: Int, val kernelSize: Pair<Int, Int>, val stride: Pair<Int, Int> = 1 to 1, val padding: Pair<Int, Int> = 0 to 0, val outputPadding: Pair<Int, Int> = 0 to 0, val dilation: Pair<Int, Int> = 1 to 1, val groups: Int = 1, val bias: Boolean = true, val name: String = "TransposedConv2d", initWeights: Tensor<T, V>, initBias: Tensor<T, V>? = null) : Module<T, V> , ModuleParameters<T, V>

Transposed Convolution (Deconvolution) layer.

Link copied to clipboard
data class TransposedConvInfo(val kernelSize: Pair<Int, Int>, val stride: Pair<Int, Int>, val padding: Pair<Int, Int>, val outputPadding: Pair<Int, Int>, val dilation: Pair<Int, Int>, val groups: Int, val upsamplingFactor: Pair<Double, Double>, val parameterCount: Long, val is2xUpsampling: Boolean, val isStandard: Boolean)

Data class containing information about transposed convolution configuration.

Link copied to clipboard
class Upsample2d<T : DType, V>(val scale: Pair<Int, Int> = 2 to 2, val mode: UpsampleMode = UpsampleMode.Nearest, val alignCorners: Boolean = false, val name: String = "Upsample2d") : Module<T, V>

2D upsampling layer for increasing spatial resolution.

Functions

Link copied to clipboard
fun <T : DType, U : DType, V> compose(d: DualModule<T, U, V>, u: Module<U, V>): DualModule<T, U, V>

fun <T : DType, U : DType, V> compose(u: Module<T, V>, d: DualModule<T, U, V>): DualModule<T, U, V>

Composition helpers to chain unary and dual modules.

Link copied to clipboard

Creates a context for the DSL with the given configuration.

Link copied to clipboard
operator fun <T : DType, V> Module<T, V>.invoke(input: Tensor<T, V>, ctx: ExecutionContext): Tensor<T, V>

Convenience operator to call a Module with an explicit ExecutionContext. This does not re-introduce the legacy context-less invoke; callers must pass ctx.

Link copied to clipboard
inline fun <T : DType, V> NeuralNetworkExecutionContext.network(executionContext: ExecutionContext, content: NeuralNetworkDsl<T, V>.() -> Unit): Module<T, V>

Extension function to create a network within a NetworkContext. This bridges the context wrapper with the network DSL using the context's tensor factory.

Link copied to clipboard
fun <T : DType, V> trainStep(model: Module<T, V>, loss: Loss, optimizer: Optimizer, ctx: ExecutionContext, x: Tensor<T, V>, y: Tensor<out DType, *>): Tensor<T, V>

Perform a single training step: forward, backward, optimizer step, and zero grad.