Update docs and example BUILD files to reflect the switch from zig_cc_binary to zig_binary.
This commit is contained in:
parent
cf00506dbb
commit
a512b9c8a2
@ -41,9 +41,9 @@ use their rules to define our 5 additional targets:
|
|||||||
load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
|
load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
|
||||||
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
|
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
|
||||||
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
|
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
|
||||||
load("@zml//bazel:zig.bzl", "zig_cc_binary")
|
load("@rules_zig//zig:defs.bzl", "zig_binary")
|
||||||
|
|
||||||
zig_cc_binary(
|
zig_binary(
|
||||||
name = "simple_layer",
|
name = "simple_layer",
|
||||||
main = "main.zig",
|
main = "main.zig",
|
||||||
deps = [
|
deps = [
|
||||||
@ -248,10 +248,10 @@ load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")
|
|||||||
load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
|
load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
|
||||||
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
|
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
|
||||||
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
|
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
|
||||||
load("@zml//bazel:zig.bzl", "zig_cc_binary")
|
load("@rules_zig//zig:defs.bzl", "zig_binary")
|
||||||
|
|
||||||
# The executable
|
# The executable
|
||||||
zig_cc_binary(
|
zig_binary(
|
||||||
name = "mnist",
|
name = "mnist",
|
||||||
args = [
|
args = [
|
||||||
"$(location @com_github_ggerganov_ggml_mnist//file)",
|
"$(location @com_github_ggerganov_ggml_mnist//file)",
|
||||||
|
|||||||
@ -150,9 +150,9 @@ pub fn asyncMain() !void {
|
|||||||
And add a `zig_cc_binary` target in `my_project/BUILD.bazel`:
|
And add a `zig_cc_binary` target in `my_project/BUILD.bazel`:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
load("@zml//bazel:zig.bzl", "zig_cc_binary")
|
load("@rules_zig//zig:defs.bzl", "zig_binary")
|
||||||
|
|
||||||
zig_cc_binary(
|
zig_binary(
|
||||||
name = "torch2zml",
|
name = "torch2zml",
|
||||||
main = "torch2zml.zig",
|
main = "torch2zml.zig",
|
||||||
deps = [
|
deps = [
|
||||||
@ -246,7 +246,7 @@ We can test the MLP layer with the `zml.testing.testLayer` utility:
|
|||||||
```zig
|
```zig
|
||||||
pub fn asyncMain() !void {
|
pub fn asyncMain() !void {
|
||||||
...
|
...
|
||||||
|
|
||||||
var ctx = try zml.Context.init();
|
var ctx = try zml.Context.init();
|
||||||
defer ctx.deinit();
|
defer ctx.deinit();
|
||||||
const platform = ctx.autoPlatform(.{});
|
const platform = ctx.autoPlatform(.{});
|
||||||
@ -293,5 +293,5 @@ During this phase, you have three kinds of errors that can appear:
|
|||||||
"C,W,H" of tensors, you can port this to actual tensor attributes using
|
"C,W,H" of tensors, you can port this to actual tensor attributes using
|
||||||
`x.withTags(.{.c, .w, .h})`, and use those tags (eg `.c`) to refer to axes
|
`x.withTags(.{.c, .w, .h})`, and use those tags (eg `.c`) to refer to axes
|
||||||
instead of offsets. E.g. in Pytorch: `x.sum(0) # reduce over channel axis`
|
instead of offsets. E.g. in Pytorch: `x.sum(0) # reduce over channel axis`
|
||||||
becomes `x.sum(.c)`. More on this topic in
|
becomes `x.sum(.c)`. More on this topic in
|
||||||
["Working with tensors"](../tutorials/working_with_tensors.md).
|
["Working with tensors"](../tutorials/working_with_tensors.md).
|
||||||
|
|||||||
@ -352,9 +352,9 @@ As mentioned already, ZML uses Bazel; so to build our model, we just need to
|
|||||||
create a simple `BUILD.bazel` file, next to the `main.zig` file, like this:
|
create a simple `BUILD.bazel` file, next to the `main.zig` file, like this:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
load("@zml//bazel:zig.bzl", "zig_cc_binary")
|
load("@rules_zig//zig:defs.bzl", "zig_binary")
|
||||||
|
|
||||||
zig_cc_binary(
|
zig_binary(
|
||||||
name = "simple_layer",
|
name = "simple_layer",
|
||||||
main = "main.zig",
|
main = "main.zig",
|
||||||
deps = [
|
deps = [
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||||
load("//bazel:zig.bzl", "zig_cc_binary")
|
load("@rules_zig//zig:defs.bzl", "zig_binary")
|
||||||
|
|
||||||
zig_cc_binary(
|
zig_binary(
|
||||||
name = "benchmark",
|
name = "benchmark",
|
||||||
main = "main.zig",
|
main = "main.zig",
|
||||||
deps = [
|
deps = [
|
||||||
|
|||||||
@ -2,9 +2,9 @@ load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
|
|||||||
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
|
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
|
||||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||||
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
|
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
|
||||||
load("//bazel:zig.bzl", "zig_cc_binary")
|
load("@rules_zig//zig:defs.bzl", "zig_binary")
|
||||||
|
|
||||||
zig_cc_binary(
|
zig_binary(
|
||||||
name = "llama",
|
name = "llama",
|
||||||
srcs = [
|
srcs = [
|
||||||
"llama.zig",
|
"llama.zig",
|
||||||
@ -18,9 +18,9 @@ zig_cc_binary(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO(steeve): Re-enable when rules_zig linkmode is fixed.
|
# TODO(steeve): Re-enable with a small, tokenless huggingface model.
|
||||||
#
|
#
|
||||||
# zig_cc_binary(
|
# zig_test(
|
||||||
# name = "test-implementation",
|
# name = "test-implementation",
|
||||||
# srcs = ["llama.zig"],
|
# srcs = ["llama.zig"],
|
||||||
# args = [
|
# args = [
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||||
load("//bazel:zig.bzl", "zig_cc_binary")
|
load("@rules_zig//zig:defs.bzl", "zig_binary")
|
||||||
|
|
||||||
zig_cc_binary(
|
zig_binary(
|
||||||
name = "mnist",
|
name = "mnist",
|
||||||
args = [
|
args = [
|
||||||
"$(location @mnist//:mnist.pt)",
|
"$(location @mnist//:mnist.pt)",
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||||
load("//bazel:zig.bzl", "zig_cc_binary")
|
load("@rules_zig//zig:defs.bzl", "zig_binary")
|
||||||
|
|
||||||
zig_cc_binary(
|
zig_binary(
|
||||||
name = "modernbert",
|
name = "modernbert",
|
||||||
srcs = ["modernbert.zig"],
|
srcs = ["modernbert.zig"],
|
||||||
args = [
|
args = [
|
||||||
|
|||||||
@ -2,9 +2,9 @@ load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
|
|||||||
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
|
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
|
||||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||||
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
|
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
|
||||||
load("//bazel:zig.bzl", "zig_cc_binary")
|
load("@rules_zig//zig:defs.bzl", "zig_binary")
|
||||||
|
|
||||||
zig_cc_binary(
|
zig_binary(
|
||||||
name = "simple_layer",
|
name = "simple_layer",
|
||||||
main = "main.zig",
|
main = "main.zig",
|
||||||
deps = [
|
deps = [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user