Table of Contents

Class HardTanhOp

Namespace
AiDotNet.JitCompiler.IR.Operations
Assembly
AiDotNet.dll

Represents Hard Tanh activation in the IR.

public class HardTanhOp : IROp
Inheritance
HardTanhOp
Inherited Members

Remarks

Computes HardTanh(x) = clip(x, -1, 1). Faster piecewise linear approximation of tanh.

Properties

MaxVal

Maximum value. Default is 1.0.

public double MaxVal { get; set; }

Property Value

double

MinVal

Minimum value. Default is -1.0.

public double MinVal { get; set; }

Property Value

double

Methods

Validate()

Validates that this operation is correctly formed.

public override bool Validate()

Returns

bool

True if valid, false otherwise.

Remarks

Basic validation checks that the operation has required information. Derived classes can override to add operation-specific validation.

For Beginners: This checks that the operation makes sense.

Basic checks:

  • Output ID is valid (non-negative)
  • Has the right number of inputs
  • Shapes are compatible

Specific operations add their own checks:

  • MatMul: inner dimensions must match
  • Conv2D: kernel size must be valid
  • Reshape: total elements must be preserved

If validation fails, the operation can't be compiled.