This repository has been archived by the owner on May 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UX] Adopt changes from tvm-main and render code with IPython.display (…
…#192) Render code with IPython.display.HTML if possible to fix the ansi-escape 24-bit rendering issue in Colab.
- Loading branch information
Showing
4 changed files
with
168 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,6 @@ | |
( | ||
"Base requirements needed to install tvm", | ||
[ | ||
"Pygments", | ||
"attrs", | ||
"cloudpickle", | ||
"decorator", | ||
|
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,55 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
import tvm | ||
from tvm.script import tir as T, relax as R | ||
|
||
|
||
def test_highlight_script(): | ||
@tvm.script.ir_module | ||
class Module: | ||
@T.prim_func | ||
def tir_matmul(x: T.handle, y: T.handle, z: T.handle) -> None: | ||
T.func_attr({"global_symbol": "tir_matmul"}) | ||
k = T.var("int32") | ||
A = T.match_buffer(x, (32, 32)) | ||
B = T.match_buffer(y, (32, 32)) | ||
C = T.match_buffer(z, (32, 32)) | ||
|
||
for (i0, j0, k0) in T.grid(32, 32, 32): | ||
with T.block(): | ||
i, j, k = T.axis.remap("SSR", [i0, j0, k0]) | ||
with T.init(): | ||
C[i, j] = 0.0 | ||
C[i, j] += A[i, k] * B[j, k] | ||
|
||
@R.function | ||
def main(x: Tensor((32, 32), "float32"), w: Tensor((32, 32), "float32")) -> Tensor: | ||
with R.dataflow(): | ||
lv0 = R.call_tir(tir_matmul, (x, w), (32, 32), dtype="float32") | ||
R.output(lv0) | ||
return lv0 | ||
|
||
Module.show() | ||
Module["main"].show() | ||
Module["tir_matmul"].show() | ||
Module["main"].show(style="light") | ||
Module["main"].show(style="dark") | ||
Module["main"].show(style="ansi") |