LayerDsl

@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class LayerDsl(val dslName: String = "")(source)

Annotation to mark Module classes for automatic Network DSL generation.

When applied to a Module class, the KSP processor will generate DSL methods for NeuralNetworkDsl that allow easy creation of the layer within the DSL.

Example:

@LayerDsl
class Conv1d<T : DType, V>(
val inChannels: Int,
val outChannels: Int,
val kernelSize: Int,
...
) : Module<T, V>()

This will generate DSL methods in NeuralNetworkDsl interface and implementations that allow building Conv1d layers within the sequential {} DSL.

Parameters

dslName

Optional custom name for the DSL method (defaults to camelCase of class name)

Properties

Link copied to clipboard