-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60b0403
commit 608a98a
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "lib-operators" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[build-dependencies] | ||
bindgen = "0.69" | ||
|
||
[dependencies] | ||
digit-layout="0.0" | ||
libc = "0.2" | ||
tensor = { path = "../tensor" } | ||
common = { path = "../common" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use std::env; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
// Tell cargo to tell rustc to link the shared library. | ||
println!("cargo:rustc-link-search=native=/home/duanchenjie/workspace/operators/build/linux/x86_64/release/"); | ||
// 链接动态库,不要包含前缀 lib 和后缀 .so | ||
println!("cargo:rustc-link-lib=dylib=operators"); // 动态库名为 liboperators.so | ||
// Link the OpenMP library | ||
println!("cargo:rustc-link-lib=dylib=gomp"); | ||
|
||
// The bindgen::Builder is the main entry point to bindgen, | ||
// and lets you build up options for the resulting bindings. | ||
let bindings = bindgen::Builder::default() | ||
.header("wrapper.h") | ||
// Generate rust style enums. | ||
.default_enum_style(bindgen::EnumVariation::Rust { | ||
non_exhaustive: true, | ||
}) | ||
// Tell cargo to invalidate the built crate whenever the wrapper changes | ||
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) | ||
// Disable layout tests because bitfields might cause issues | ||
.layout_tests(false) | ||
// Finish the builder and generate the bindings. | ||
.generate() | ||
// Unwrap the Result and panic on failure. | ||
.expect("Unable to generate bindings"); | ||
|
||
// Write the bindings to the $OUT_DIR/bindings.rs file. | ||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
bindings | ||
.write_to_file(out_path.join("bindings.rs")) | ||
.expect("Couldn't write bindings!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "/home/duanchenjie/workspace/operators/src/ops/swiglu/swiglu.h" | ||
#include "/home/duanchenjie/workspace/operators/src/ops/rotary_embedding/rotary_embedding.h" | ||
#include "/home/duanchenjie/workspace/operators/src/ops/rms_norm/rms_norm.h" | ||
#include "/home/duanchenjie/workspace/operators/src/ops/reform/reform.h" | ||
#include "/home/duanchenjie/workspace/operators/src/ops/matmul/matmul.h" | ||
#include "/home/duanchenjie/workspace/operators/src/ops/causal_softmax/causal_softmax.h" |