use crate::tensor::Tensor;
use super::module::Module;
pub struct Flatten {
from: usize,
}
impl Flatten {
pub fn new() -> Flatten {
Flatten { from: 1 }
}
pub fn from(from: usize) -> Flatten {
Flatten { from }
}
}
impl Default for Flatten {
fn default() -> Self {
Flatten::new()
}
}
impl Module for Flatten {
fn forward(&self, input: &Tensor) -> Tensor {
input.flatten_from(self.from)
}
}
pub struct Reshape {
dims: Vec<i64>,
}
impl Reshape {
pub fn new(dims: &[i64]) -> Reshape {
Reshape {
dims: dims.to_vec(),
}
}
}
impl Module for Reshape {
fn forward(&self, input: &Tensor) -> Tensor {
input.reshape(&self.dims)
}
}