-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: tracing for python source functions
This patch adds basic tracing for user python functions. The main code is in Python.lean, and depends on definitions in Basic.lean and NKI.lean, which are incomplete. As more primitives are implemented, more user kernels will be supported.
- Loading branch information
Showing
7 changed files
with
432 additions
and
27 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
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
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
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
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,49 @@ | ||
/- | ||
Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Paul Govereau | ||
-/ | ||
import NKL.KLR | ||
import NKL.Trace.Types | ||
import NKL.Trace.Builtin | ||
|
||
/- | ||
# NKI built-ins | ||
This module defines the builtin constants used by tracing for NKI kernels. | ||
-/ | ||
namespace NKL.Trace | ||
open NKL.KLR | ||
|
||
private def module (s : String) : Name × Item := | ||
let name := s.toName | ||
(name, .module name) | ||
|
||
private def const_var (s : String) : Name × Item := | ||
let name := s.toName | ||
(name, .term (.expr (.var s) (.any name))) | ||
|
||
/- | ||
Note: this object contains a bunch of architecture parameters that | ||
need to be set according to which HW we are compiling for. | ||
TODO: figure out the mechanism for this. | ||
-/ | ||
def tile_size : Global := | ||
let name := "nki.langauge.tile_size".toName | ||
{ name := name | ||
, attr := attrs | ||
, call := uncallable name | ||
} | ||
where | ||
attrs : GlobalAttr | ||
| "pmax" => return .expr (.const $ .int 128) .int | ||
| a => throw s!"unsupported attribute {a}" | ||
|
||
def NKIEnv : List (Name × Item) := | ||
[ module "nki" | ||
, module "nki.language" | ||
, const_var "nki.language.add" | ||
, const_var "nki.language.load" | ||
, const_var "nki.language.store" | ||
, ("nki.language.tile_size".toName, .global tile_size) | ||
] |
Oops, something went wrong.