teeny_core/nn/activation/relu.rs
1/*
2 * Copyright (c) 2026 Teenygrad.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17use core::marker::PhantomData;
18
19use crate::{
20 dtype::{Dtype, EagerTensor, Tensor},
21 nn::Layer,
22};
23
24/// ReLU (Rectified Linear Unit) activation layer: `max(0, x)`.
25pub struct Relu<D: Dtype, T, const RANK: usize> {
26 _pd: PhantomData<(D, T)>,
27}
28
29impl<D: Dtype, T, const RANK: usize> Default for Relu<D, T, RANK> {
30 fn default() -> Self {
31 Self { _pd: PhantomData }
32 }
33}
34
35impl<D: Dtype, T, const RANK: usize> Relu<D, T, RANK> {
36 /// Creates a new `Relu` layer.
37 pub fn new() -> Self {
38 Self::default()
39 }
40}
41
42impl<D: Dtype, T: Tensor<D, RANK> + EagerTensor, const RANK: usize> Layer<T> for Relu<D, T, RANK> {
43 type Output = T;
44
45 fn call(&self, _input: T) -> Self::Output {
46 todo!()
47 }
48}