mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-01 14:08:38 -06:00
#1539: preserve stroke corrections and current main APIs
This commit is contained in:
@@ -237,7 +237,7 @@ impl GpuEncoder {
|
||||
let px = g.upload(&pixels.contiguous()?.flatten_all()?.to_vec1::<f32>()?);
|
||||
let (mut h, mut w) = (ph / 4, pw / 4);
|
||||
let tokens = g.zeros(h * w * hidden)?;
|
||||
g.patch_embed(&px, &self.patch_w, &self.patch_b, &tokens, ph, pw, hidden)?;
|
||||
g.patch_embed(&px, &self.patch_w, &self.patch_b, &tokens, (ph, pw, hidden))?;
|
||||
let mut x = g.zeros(h * w * hidden)?;
|
||||
g.add(&tokens, &self.pos_buffer(h, w)?, &x, h * w * hidden)?;
|
||||
let mut stages: Vec<(Buf, usize, usize, usize)> = vec![];
|
||||
|
||||
@@ -169,7 +169,7 @@ impl Gpu {
|
||||
}
|
||||
|
||||
/// The patch embedding: `[3, h, w]` pixels, weight `[co, 3, 7, 7]`, bias `[co]`; output `[h/4, w/4, co]`.
|
||||
pub fn patch_embed(&self, pixels: &Buf, weight: &Buf, bias: &Buf, out: &Buf, h: usize, w: usize, co: usize) -> Result<()> {
|
||||
pub fn patch_embed(&self, pixels: &Buf, weight: &Buf, bias: &Buf, out: &Buf, (h, w, co): (usize, usize, usize)) -> Result<()> {
|
||||
let (ho, wo) = ((h + 6 - 7) / 4 + 1, (w + 6 - 7) / 4 + 1);
|
||||
need(pixels, 3 * h * w, "patch_embed pixels")?;
|
||||
need(weight, co * 3 * 49, "patch_embed weight")?;
|
||||
|
||||
@@ -340,7 +340,7 @@ fn patch_embed_rope_and_upsample_match_the_cpu_definitions() {
|
||||
let (gp, gw, gb) = (g.upload(&px), g.upload(&wt), g.upload(&bias));
|
||||
let (ho, wo) = (h / 4, w / 4);
|
||||
let out = g.zeros(ho * wo * co).unwrap();
|
||||
g.patch_embed(&gp, &gw, &gb, &out, h, w, co).unwrap();
|
||||
g.patch_embed(&gp, &gw, &gb, &out, (h, w, co)).unwrap();
|
||||
let t = Tensor::from_vec(px, (1, 3, h, w), &Device::Cpu).unwrap();
|
||||
let k = Tensor::from_vec(wt, (co, 3, 7, 7), &Device::Cpu).unwrap();
|
||||
let want =
|
||||
|
||||
Reference in New Issue
Block a user