summaryrefslogtreecommitdiff
path: root/candle-transformers/src/quantized_nn.rs
diff options
context:
space:
mode:
authorLaurent Mazare <laurent.mazare@gmail.com>2023-10-22 20:33:25 +0100
committerGitHub <noreply@github.com>2023-10-22 20:33:25 +0100
commita11af79e23179ccdd52fb97873c1bfa7b979edb4 (patch)
tree58033f3aa6ed83e6700f2b4a0e14d65a4c0e8b98 /candle-transformers/src/quantized_nn.rs
parent8a82d623e5ad919ba422bc796bd31b6fc3b91ab1 (diff)
downloadcandle-a11af79e23179ccdd52fb97873c1bfa7b979edb4.tar.gz
candle-a11af79e23179ccdd52fb97873c1bfa7b979edb4.tar.bz2
candle-a11af79e23179ccdd52fb97873c1bfa7b979edb4.zip
Add a quantized blip model. (#1155)
* Add a quantized blip model. * Integrate the quantized blip model to the actual example.
Diffstat (limited to 'candle-transformers/src/quantized_nn.rs')
-rw-r--r--candle-transformers/src/quantized_nn.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/candle-transformers/src/quantized_nn.rs b/candle-transformers/src/quantized_nn.rs
index 2941c3f0..99e8d45b 100644
--- a/candle-transformers/src/quantized_nn.rs
+++ b/candle-transformers/src/quantized_nn.rs
@@ -34,6 +34,12 @@ pub struct Linear {
bias: Option<Tensor>,
}
+impl Linear {
+ pub fn from_weights(weight: QMatMul, bias: Option<Tensor>) -> Self {
+ Self { weight, bias }
+ }
+}
+
impl Module for Linear {
fn forward(&self, x: &Tensor) -> candle::Result<Tensor> {
let x = x.apply(&self.weight)?;