Skip to content

Instantly share code, notes, and snippets.

@pashu123
Created June 1, 2023 16:51
Show Gist options
  • Save pashu123/7f6ac404e16df6e5f5ee69904a06e172 to your computer and use it in GitHub Desktop.
Save pashu123/7f6ac404e16df6e5f5ee69904a06e172 to your computer and use it in GitHub Desktop.
from iree import runtime as ireert
from iree.compiler import compile_str
import numpy as np
import os
with open(os.path.join("vicuna_fp32_cpu.vmfb"), "rb") as mlir_file:
flatbuffer_blob = mlir_file.read()
backend = "llvm-cpu"
args = ["--iree-llvmcpu-target-cpu-features=host"]
config = ireert.Config("local-task")
vm_module = ireert.VmModule.from_flatbuffer(config.vm_instance, flatbuffer_blob)
ctx = ireert.SystemContext(config=config)
ctx.add_vm_module(vm_module)
complex_compiled = ctx.modules.module
input1 = np.load("inp1.npy")
input2 = np.load("inp2.npy")
x = complex_compiled.forward(input1, input2)
print(x.to_host())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment