MLX linear layer with weight, bias, and quantization support.
// Source: https://github.com/kellyvv/PhoneClaw | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
// Copyright © 2024 Apple Inc.
import Foundation
import MLX
/// A placeholder identity operator that is argument-insensitive.
public class Identity: Module, UnaryLayer {
public func callAsFunction(_ x: MLXArray) -> MLXArray {
x
}
}
/// Applies an affine transformation to the input.
///
/// Concretely:
///
/// ```swift
/// matmul(x, W) + b
/// ```
///
/// where `W` has shape `[inputDimensions, outputDimensions]` and `b` has
/// shape `[outputDimensions]`.
///
/// The values are initialized from the uniform distribution:
///
/// ```swift
/// scale = sqrt(1.0 / inputDime
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key