Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace opaque return types in optim #1767

Merged
merged 5 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/burn-core/src/optim/adagrad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{

use super::{
decay::{WeightDecay, WeightDecayConfig},
Optimizer, SimpleOptimizer,
SimpleOptimizer,
};
use crate::config::Config;
use crate::optim::adaptor::OptimizerAdaptor;
Expand Down Expand Up @@ -79,7 +79,9 @@ impl AdaGradConfig {
/// # Returns
///
/// Returns an optimizer that can be used to optimize a module.
pub fn init<B: AutodiffBackend, M: AutodiffModule<B>>(&self) -> impl Optimizer<M, B> {
pub fn init<B: AutodiffBackend, M: AutodiffModule<B>>(
&self,
) -> OptimizerAdaptor<AdaGrad<B::InnerBackend>, M, B> {
let optim = AdaGrad {
lr_decay: LrDecay {
lr_decay: self.lr_decay,
Expand Down
6 changes: 4 additions & 2 deletions crates/burn-core/src/optim/adam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{

use super::{
decay::{WeightDecay, WeightDecayConfig},
Optimizer, SimpleOptimizer,
SimpleOptimizer,
};
use crate::config::Config;
use crate::optim::adaptor::OptimizerAdaptor;
Expand Down Expand Up @@ -85,7 +85,9 @@ impl AdamConfig {
/// # Returns
///
/// Returns an optimizer that can be used to optimize a module.
pub fn init<B: AutodiffBackend, M: AutodiffModule<B>>(&self) -> impl Optimizer<M, B> {
pub fn init<B: AutodiffBackend, M: AutodiffModule<B>>(
&self,
) -> OptimizerAdaptor<Adam<B::InnerBackend>, M, B> {
let optim = Adam {
momentum: AdaptiveMomentum {
beta_1: self.beta_1,
Expand Down
6 changes: 4 additions & 2 deletions crates/burn-core/src/optim/adamw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
};
use std::marker::PhantomData;

use super::{Optimizer, SimpleOptimizer};
use super::SimpleOptimizer;
use crate::config::Config;
use crate::optim::adaptor::OptimizerAdaptor;
use crate::tensor::{backend::AutodiffBackend, Tensor};
Expand Down Expand Up @@ -83,7 +83,9 @@ impl AdamWConfig {
/// # Returns
///
/// Returns an optimizer that can be used to optimize a module.
pub fn init<B: AutodiffBackend, M: AutodiffModule<B>>(&self) -> impl Optimizer<M, B> {
pub fn init<B: AutodiffBackend, M: AutodiffModule<B>>(
&self,
) -> OptimizerAdaptor<AdamW<B::InnerBackend>, M, B> {
let optim = AdamW {
momentum: AdaptiveMomentumW {
beta_1: self.beta_1,
Expand Down
Loading