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
// Binary Search Tree - Implemenation in C++
// Simple program to create a BST of integers and search an element in it
#include<iostream>
using namespace std;
//Definition of Node for Binary search tree
struct BstNode {
int data;
BstNode* left;
BstNode* right;
};
import numpy as np
import ctypes
import gc, sys
from mlir.ir import *
from mlir.passmanager import *
from mlir.execution_engine import *
class MemRefDescriptor(ctypes.Structure):
""" Creates a ctype struct for memref descriptor"""
import pandas as pd
import re
import numpy as np
from sys import argv
# `xls_file` and `td files` are total_ops and generatedAtenOps.td file
# respectively.
xls_file = argv[1]
td_file = argv[2]
from transformers import (
AutoConfig,
AutoModelForCausalLM,
AutoModelForMaskedLM,
AutoModelForSeq2SeqLM,
ReformerConfig,
BigBirdConfig,
BertConfig,
)
import transformers
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<[4,512,768],f32>}, %arg2: !torch.tensor {torch.type_bound = !torch.vtensor<[4,512,1],f32>}, %arg3: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg4: !torch.tensor {torch.type_bound = !torch.vtensor<[4,512,1],f32>}, %arg5: !torch.tensor {torch.type_bound = !torch.vtensor<[4,12,512,512],f32>}, %arg6: !torch.tensor {torch.type_bound = !torch.vtensor<[4,512,768],f32>}, %arg7: !torch.tensor {torch.type_bound = !torch.vtensor<[768,3072],f32>}, %arg8: !torch.tensor {torch.type_bound = !torch.vtensor<[4,512,1],f32>}, %arg9: !torch.tensor {torch.type_bound = !torch.vtensor<[2048,768],f32>}, %arg10: !torch.tensor {torch.type_bound = !torch.vtensor<[4,12,512,512],f32>}, %arg11: !torch.tensor {torch.type_bound = !
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<[768],f32>}, %arg2: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg3: !torch.tensor {torch.type_bound = !torch.vtensor<[512,768],f32>}, %arg4: !torch.tensor {torch.type_bound = !torch.vtensor<[2,768],f32>}, %arg5: !torch.tensor {torch.type_bound = !torch.vtensor<[30522,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,768],f32>}, %arg10: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg11: !torch.tensor {torch.type_bound = !torch.vtensor<[768,768],f32>}, %arg1
This file has been truncated, but you can view the full file.
// -----// IR Dump After SymbolDCE //----- //
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<[768],f32>}, %arg2: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg3: !torch.tensor {torch.type_bound = !torch.vtensor<[512,768],f32>}, %arg4: !torch.tensor {torch.type_bound = !torch.vtensor<[2,768],f32>}, %arg5: !torch.tensor {torch.type_bound = !torch.vtensor<[30522,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,768],f32>}, %arg10: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg11: !torch.tensor {torch.type
#loc0 = loc(unknown)
module attributes {torch.debug_module_name = "MobilenetV3Module"} {
func @forward(%arg0: !torch.vtensor<[?,3,?,?],f32> loc(unknown)) -> !torch.vtensor {
%0 = torch.vtensor.literal(dense<0.000000e+00> : tensor<1000xf32>) : !torch.vtensor<[1000],f32> loc(#loc0)
%1 = torch.vtensor.literal(opaque<"elided_large_const", "0xDEADBEEF"> : tensor<1000x1024xf32>) : !torch.vtensor<[1000,1024],f32> loc(#loc0)
%2 = torch.vtensor.literal(dense<0.000000e+00> : tensor<1024xf32>) : !torch.vtensor<[1024],f32> loc(#loc0)
%3 = torch.vtensor.literal(opaque<"elided_large_const", "0xDEADBEEF"> : tensor<1024x576xf32>) : !torch.vtensor<[1024,576],f32> loc(#loc0)
%4 = torch.vtensor.literal(dense<0.000000e+00> : tensor<576xf32>) : !torch.vtensor<[576],f32> loc(#loc0)
%5 = torch.vtensor.literal(dense<1.000000e+00> : tensor<576xf32>) : !torch.vtensor<[576],f32> loc(#loc0)
%none = torch.constant.none loc(#loc1)
We couldn’t find that file to show.
from PIL import Image
import requests
import torch
import torchvision.models as models
from torchvision import transforms
from torch_mlir.dialects.torch.importer.jit_ir import ClassAnnotator, ModuleBuilder
from torch_mlir.passmanager import PassManager
from torch_mlir_e2e_test.linalg_on_tensors_backends.abc import LinalgOnTensorsBackend