sarah-ek / gemm Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hi,
Are you thinking of adding support for Neon and Wasm architecture anypoint in the road map of this crate ?
These global flags need to be static
, not const
. const
is effectively copy+paste of the RHS, so you can't store anything at runtime.
Lines 105 to 110 in 2283886
Hi @sarah-ek,
I have an operation where I need to apply matrix multiplication to f32,f16 to obtain f32 matrix. The addition and multiplication should be done in f32 format.
So: Matmul(f16,f32) -> f32
To do this operation with your package, at the moment I saving( and turning) f16 matrix into f32 buffer matrix, then using gemm for f32xf32 matrix multiplication.
More specifically, I used your f16 matmul code and transformed some part of it so that it is mixed precision.
I am not sure how optimized my code is. If possible I would like to know if you will add support for this.
This type of operation is being adapted more and more in the context of large ML models.
I'm not sure if this is a bug or something else, but I'm hitting this explicit panic in gemm dispatch when using f16.
This is because I'm using f16 from half-rs
main branch (half = { git = "https://github.com/starkat99/half-rs.git", branch = "main", optional = true, features = ["num-traits", "rand_distr"] }
, whereas this crate is using half-rs
from crates.io.
You can see this results in two different versions being compiled by cargo tree
:
dfdx v0.11.2 (C:\Users\clowm\Documents\programming\dfdx)
├── half v3.0.0-dev (https://github.com/starkat99/half-rs.git?branch=main#1d7f8622)
├── gemm v0.15.2
...
│ ├── gemm-f16 v0.15.2
...
│ │ ├── half v2.2.1
│ │ │ └── num-traits v0.2.15 (*)
...
The following shows that the two type ids are different for me:
use std::any::TypeId;
fn main() {
println!("half f16 = {:?}", TypeId::of::<half::f16>());
println!("gemm f16 = {:?}", TypeId::of::<gemm::f16>());
}
Outputs:
half f16 = TypeId { t: 2603904629608812109 }
gemm f16 = TypeId { t: 1360783734638873359 }
I'm not really sure. Do you have thoughts on best approach here? This could also be an issue if using different versions for num_complex
crate.
The usages I'm seeing are:
rayon::current_num_threads()
used a couple places in gemmRayon(0)
, does this mean something special or is rayon with 0 threads (i guess sequential?)For a general purpose library that is not exposing gemm to external users, how should parallelism be configured?
There is a comment in the code base:
https://github.com/sarah-ek/gemm/blob/main/gemm/src/gemm.rs#L151
which says that gemm panics if T is not f32 and f64. But I was able to run it with f16 type as well.
I guess this is a typo since the function is also used by gemm_dispatch
function to matmul on f16 data type ??
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.