Spaces:
Sleeping
Sleeping
Commit
·
1c62ccb
1
Parent(s):
9e585ee
iree
Browse files- Dockerfile +10 -4
- main.py +5 -3
Dockerfile
CHANGED
@@ -29,14 +29,20 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
29 |
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
30 |
apt-get -y update && apt-get install -y mlir-18-tools llvm-18
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
# Install pytorch-mlir
|
33 |
|
34 |
-
RUN pip install --pre torch-mlir torch \
|
35 |
-
--extra-index-url https://download.pytorch.org/whl/nightly/cpu \
|
36 |
-
-f https://github.com/llvm/torch-mlir-release/releases/expanded_assets/dev-wheels
|
37 |
|
38 |
# Add PyTorch-MLIR tools to PATH
|
39 |
-
ENV PATH="/root/.local/bin:${PATH}"
|
40 |
|
41 |
# Verify installations
|
42 |
RUN python -c "import torch; print(torch.__version__)" && \
|
|
|
29 |
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
30 |
apt-get -y update && apt-get install -y mlir-18-tools llvm-18
|
31 |
|
32 |
+
# IREE
|
33 |
+
RUN pip install \
|
34 |
+
--index-url https://download.pytorch.org/whl/test/cpu torch==2.4.1
|
35 |
+
RUN pip install iree-turbine
|
36 |
+
|
37 |
+
|
38 |
# Install pytorch-mlir
|
39 |
|
40 |
+
#RUN pip install --pre torch-mlir torch \
|
41 |
+
# --extra-index-url https://download.pytorch.org/whl/nightly/cpu \
|
42 |
+
# -f https://github.com/llvm/torch-mlir-release/releases/expanded_assets/dev-wheels
|
43 |
|
44 |
# Add PyTorch-MLIR tools to PATH
|
45 |
+
#ENV PATH="/root/.local/bin:${PATH}"
|
46 |
|
47 |
# Verify installations
|
48 |
RUN python -c "import torch; print(torch.__version__)" && \
|
main.py
CHANGED
@@ -13,13 +13,15 @@ def process_code(pytorch_code):
|
|
13 |
code_file.flush()
|
14 |
|
15 |
# Step 2: Run the PyTorch code to generate TorchScript
|
16 |
-
script_output_path = tempfile.NamedTemporaryFile(delete=False, suffix=".pt").name
|
17 |
subprocess.run(
|
18 |
-
["python3", code_file.name
|
19 |
check=True,
|
20 |
capture_output=True,
|
21 |
)
|
22 |
|
|
|
|
|
23 |
# Step 3: Convert TorchScript to MLIR (torch dialect)
|
24 |
torch_mlir_path = tempfile.NamedTemporaryFile(delete=False, suffix=".mlir").name
|
25 |
subprocess.run(
|
@@ -70,7 +72,7 @@ iface = gr.Interface(
|
|
70 |
fn=process_code,
|
71 |
inputs="text",
|
72 |
outputs=[
|
73 |
-
gr.Textbox(label="Torch Dialect"),
|
74 |
gr.Textbox(label="Linalg Dialect"),
|
75 |
gr.Textbox(label="GPU Dialect"),
|
76 |
gr.Textbox(label="LLVM Dialect"),
|
|
|
13 |
code_file.flush()
|
14 |
|
15 |
# Step 2: Run the PyTorch code to generate TorchScript
|
16 |
+
#script_output_path = tempfile.NamedTemporaryFile(delete=False, suffix=".pt").name
|
17 |
subprocess.run(
|
18 |
+
["python3", code_file.name],
|
19 |
check=True,
|
20 |
capture_output=True,
|
21 |
)
|
22 |
|
23 |
+
print("Converted to onnx.")
|
24 |
+
|
25 |
# Step 3: Convert TorchScript to MLIR (torch dialect)
|
26 |
torch_mlir_path = tempfile.NamedTemporaryFile(delete=False, suffix=".mlir").name
|
27 |
subprocess.run(
|
|
|
72 |
fn=process_code,
|
73 |
inputs="text",
|
74 |
outputs=[
|
75 |
+
gr.Textbox(label="Torch Dialect", lines=10),
|
76 |
gr.Textbox(label="Linalg Dialect"),
|
77 |
gr.Textbox(label="GPU Dialect"),
|
78 |
gr.Textbox(label="LLVM Dialect"),
|