VarBuilder cleanup (#627)

* VarBuilder cleanup.

* Implement the basic varbuilders.

* Add the sharded code.

* Proper support for tensor sharding.
This commit is contained in:
Laurent Mazare
2023-08-27 18:03:26 +01:00
committed by GitHub
parent be471d50ab
commit 4c338b0cd9
12 changed files with 409 additions and 291 deletions

View File

@ -128,9 +128,9 @@ pub fn layer_norm<C: Into<LayerNormConfig>>(
vb: crate::VarBuilder,
) -> Result<LayerNorm> {
let config = config.into();
let weight = vb.get_or_init(size, "weight", crate::Init::Const(1.))?;
let weight = vb.get_with_hints(size, "weight", crate::Init::Const(1.))?;
let bias = if config.affine {
Some(vb.get_or_init(size, "bias", crate::Init::Const(0.))?)
Some(vb.get_with_hints(size, "bias", crate::Init::Const(0.))?)
} else {
None
};