forked from modular/modular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_op_example.bzl
More file actions
46 lines (43 loc) · 1.4 KB
/
custom_op_example.bzl
File metadata and controls
46 lines (43 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Custom Op example helpers to reduce boilerplate in BUILD.bazel file."""
load("//bazel:api.bzl", "modular_py_binary", "modular_run_binary_test", "requirement")
def custom_op_example_py_binary(
name,
srcs,
create_test = True,
extra_data = [],
extra_deps = []):
modular_py_binary(
name = name,
srcs = srcs,
data = [
":kernel_sources",
# Ensure that the `mojo` tool is available.
"//KGEN/tools/mojo",
] + extra_data,
env = {
# Note: This relative path works because the default working directory
# for a `modular_py_binary` target is the runfiles root directory.
"PATH": "KGEN/tools/mojo:/usr/bin:/bin",
},
use_sitecustomize = True,
imports = ["."],
mojo_deps = [
"@mojo//:compiler",
"@mojo//:layout",
"@mojo//:stdlib",
"@mojo//:tensor_internal",
],
deps = [
"//SDK/lib/API/python/max/driver",
"//SDK/lib/API/python/max/engine",
"//SDK/lib/API/python/max/graph",
requirement("numpy"),
] + extra_deps,
)
# Run each example as a simple non-zero-exit-code test.
if create_test:
modular_run_binary_test(
name = name + ".example-test",
args = [],
binary = name,
)