Skip to content

Instantly share code, notes, and snippets.

View pashu123's full-sized avatar
๐Ÿ˜‡
Working from home

Prashant Kumar pashu123

๐Ÿ˜‡
Working from home
View GitHub Profile
from PIL import Image
import requests
import torch
import torchvision.models as models
from torchvision import transforms
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from torch_mlir.dialects.torch.importer.jit_ir import ClassAnnotator, ModuleBuilder
from torch_mlir.passmanager import PassManager
This file has been truncated, but you can view the full file.
/home/prashant/run-iree/venv/lib/python3.9/site-packages/torch/nn/modules/module.py:1383: UserWarning: positional arguments and argument "destination" are deprecated. nn.Module.state_dict will not accept them in the future. Refer to https://pytorch.org/docs/master/generated/torch.nn.Module.html#torch.nn.Module.state_dict for details.
warnings.warn(
/home/prashant/run-iree/venv/lib/python3.9/site-packages/transformers/models/gpt2/modeling_gpt2.py:196: TracerWarning: Converting a tensor to a Python float might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
attn_weights = attn_weights / (float(value.size(-1)) ** 0.5)
Traceback (most recent call last):
File "/home/prashant/run-iree/models/hugging_face_models.py", line 33, in <module>
results = shark_inference(
File "/home/prashant/run-iree/models/shark_runner.py", line 88, in shark_inference
m
module attributes {torch.debug_module_name = "GraphModule"} {
func private @__torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule.forward(%arg0: !torch.nn.Module<"__torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule">, %arg1: !torch.tensor {torch.type_bound = !torch.vtensor<[50257,768],f32>}, %arg2: !torch.tensor {torch.type_bound = !torch.vtensor<[2304],f32>}, %arg3: !torch.tensor {torch.type_bound = !torch.vtensor<[768,2304],f32>}, %arg4: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg5: !torch.tensor {torch.type_bound = !torch.vtensor<[768,768],f32>}, %arg6: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg7: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg8: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg9: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg10: !torch.tensor {torch.type_bound = !torch.vtensor<[3072],f32>}, %arg11: !torch.tensor {torch.type_bound = !torch.vtensor<[768,3072],f32>}, %ar
This file has been truncated, but you can view the full file.
module attributes {torch.debug_module_name = "GraphModule"} {
func private @__torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule.forward(%arg0: !torch.nn.Module<"__torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule">, %arg1: !torch.tensor {torch.type_bound = !torch.vtensor<[50265,768],f32>}, %arg2: !torch.tensor {torch.type_bound = !torch.vtensor<[1026,768],f32>}, %arg3: !torch.tensor {torch.type_bound = !torch.vtensor<[50265,768],f32>}, %arg4: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg5: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg6: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg7: !torch.tensor {torch.type_bound = !torch.vtensor<[768,768],f32>}, %arg8: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg9: !torch.tensor {torch.type_bound = !torch.vtensor<[768,768],f32>}, %arg10: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg11: !torch.tensor {torch.type_bound = !torch.vtensor<[768,768],f32
module attributes {torch.debug_module_name = "GraphModule"} {
func private @__torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule.forward(%arg0: !torch.nn.Module<"__torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule">, %arg1: !torch.tensor {torch.type_bound = !torch.vtensor<[1024],f32>}, %arg2: !torch.tensor {torch.type_bound = !torch.vtensor<[1024],f32>}, %arg3: !torch.tensor {torch.type_bound = !torch.vtensor<[4096,1024],f32>}, %arg4: !torch.tensor {torch.type_bound = !torch.vtensor<[2,1024],f32>}, %arg5: !torch.tensor {torch.type_bound = !torch.vtensor<[50358,1024],f32>}, %arg6: !torch.tensor {torch.type_bound = !torch.vtensor<[1024],f32>}, %arg7: !torch.tensor {torch.type_bound = !torch.vtensor<[1024],f32>}, %arg8: !torch.tensor {torch.type_bound = !torch.vtensor<[1024],f32>}, %arg9: !torch.tensor {torch.type_bound = !torch.vtensor<[1024,1024],f32>}, %arg10: !torch.tensor {torch.type_bound = !torch.vtensor<[1024],f32>}, %arg11: !torch.tensor {torch.type_bound = !torch.vtensor<[1024,1024
graph(%self : __torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule,
%primals_1.1 : Tensor,
%primals_2.1 : Tensor,
%primals_3.1 : Tensor,
%primals_4.1 : Tensor,
%primals_5.1 : Tensor,
%primals_6.1 : Tensor,
%primals_7.1 : Tensor,
%primals_8.1 : Tensor,
%primals_9.1 : Tensor,
This file has been truncated, but you can view the full file.
module attributes {torch.debug_module_name = "GraphModule"} {
func private @__torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule.forward(%arg0: !torch.nn.Module<"__torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule">, %arg1: !torch.tensor {torch.type_bound = !torch.vtensor<[160],f32>}, %arg2: !torch.tensor {torch.type_bound = !torch.vtensor<[160,96,1,1],f32>}, %arg3: !torch.tensor {torch.type_bound = !torch.vtensor<[32],f32>}, %arg4: !torch.tensor {torch.type_bound = !torch.vtensor<[32,3,7,7],f32>}, %arg5: !torch.tensor {torch.type_bound = !torch.vtensor<[8],f32>}, %arg6: !torch.tensor {torch.type_bound = !torch.vtensor<[8,32,1,1],f32>}, %arg7: !torch.tensor {torch.type_bound = !torch.vtensor<[8],f32>}, %arg8: !torch.tensor {torch.type_bound = !torch.vtensor<[8,8,3,3],f32>}, %arg9: !torch.tensor {torch.type_bound = !torch.vtensor<[32],f32>}, %arg10: !torch.tensor {torch.type_bound = !torch.vtensor<[32,8,1,1],f32>}, %arg11: !torch.tensor {torch.type_bound = !torch.vtensor<[8],f32>}, %arg12:
module attributes {torch.debug_module_name = "GraphModule"} {
func private @__torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule.forward(%arg0: !torch.nn.Module<"__torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule">, %arg1: !torch.tensor {torch.type_bound = !torch.vtensor<[64],f32>}, %arg2: !torch.tensor {torch.type_bound = !torch.vtensor<[64],f32>}, %arg3: !torch.tensor {torch.type_bound = !torch.vtensor<[64,3,7,7],f32>}, %arg4: !torch.tensor {torch.type_bound = !torch.vtensor<[1000],f32>}, %arg5: !torch.tensor {torch.type_bound = !torch.vtensor<[1000,2048],f32>}, %arg6: !torch.tensor {torch.type_bound = !torch.vtensor<[64],f32>}, %arg7: !torch.tensor {torch.type_bound = !torch.vtensor<[64],f32>}, %arg8: !torch.tensor {torch.type_bound = !torch.vtensor<[64],f32>}, %arg9: !torch.tensor {torch.type_bound = !torch.vtensor<[64],f32>}, %arg10: !torch.tensor {torch.type_bound = !torch.vtensor<[256],f32>}, %arg11: !torch.tensor {torch.type_bound = !torch.vtensor<[256],f32>}, %arg12: !torch.tens
module attributes {torch.debug_module_name = "GraphModule"} {
func private @__torch__.torch.fx.graph_module.___torch_mangle_2.GraphModule.forward(%arg0: !torch.nn.Module<"__torch__.torch.fx.graph_module.___torch_mangle_2.GraphModule">, %arg1: !torch.tensor {torch.type_bound = !torch.vtensor<[0],f32>}, %arg2: !torch.tensor {torch.type_bound = !torch.vtensor<[256],f32>}, %arg3: !torch.tensor {torch.type_bound = !torch.vtensor<[128],f32>}, %arg4: !torch.tensor {torch.type_bound = !torch.vtensor<[2048,512,1,1],f32>}, %arg5: !torch.tensor {torch.type_bound = !torch.vtensor<[1,256,14,14],f32>}, %arg6: !torch.tensor {torch.type_bound = !torch.vtensor<[1,64,56,56],f32>}, %arg7: !torch.tensor {torch.type_bound = !torch.vtensor<[256],f32>}, %arg8: !torch.tensor {torch.type_bound = !torch.vtensor<[1,128,28,28],f32>}, %arg9: !torch.tensor {torch.type_bound = !torch.vtensor<[1024],f32>}, %arg10: !torch.tensor {torch.type_bound = !torch.vtensor<[1,128,28,28],f32>}, %arg11: !torch.tensor {torch.type_bound = !torch.vtensor
This file has been truncated, but you can view the full file.
module attributes {torch.debug_module_name = "Generator"} {
func private @__torch__.torch.nn.modules.conv.ConvTranspose2d.forward(%arg0: !torch.nn.Module<"__torch__.torch.nn.modules.conv.ConvTranspose2d">, %arg1: !torch.tensor, %arg2: !torch.optional<list<int>>) -> !torch.tensor {
%int4 = torch.constant.int 4
%int0_0 = torch.constant.int 0
%int1_1 = torch.constant.int 1
%46 = torch.prim.ListConstruct %int1_1, %int1_1 : (!torch.int, !torch.int) -> !torch.list<int>
%47 = torch.prim.ListConstruct %int0_0, %int0_0 : (!torch.int, !torch.int) -> !torch.list<int>
%48 = torch.prim.ListConstruct %int4, %int4 : (!torch.int, !torch.int) -> !torch.list<int>
%49 = torch.prim.ListConstruct %int1_1, %int1_1 : (!torch.int, !torch.int) -> !torch.list<int>
%50 = torch.derefine %49 : !torch.list<int> to !torch.optional<list<int>>