Skip to content

Instantly share code, notes, and snippets.

View renxida's full-sized avatar
💭
Looking for a job

Xida Ren (Cedar) renxida

💭
Looking for a job
  • Seattle, WA
  • 18:42 (UTC -07:00)
View GitHub Profile
import gc
import sys
import torch
import torch_mlir
batch_size = 1
seq_len = 3
input_size = 5
hidden_size = 5
kernel_size = 3
Add
AveragePool
BatchNormalization
Cast
Clip
Concat
Constant
ConstantOfShape
Conv
// torch-mlir/.vscode/settings.json
{
"files.associations": {
"*.inc": "cpp",
"ranges": "cpp",
"regex": "cpp",
"functional": "cpp",
"chrono": "cpp",
"__functional_03": "cpp",
"target": "cpp",
OVERVIEW: MLIR modular optimizer driver
Available Dialects: builtin, chlo, complex, func, linalg, memref, ml_program, scf, sparse_tensor, stablehlo, tensor, tm_tensor, torch, torch_c, tosa, vhlo
USAGE: torch-mlir-opt [options] <input file>
OPTIONS:
Color Options:
--color - Use colors in output (default=autodetect)
// RUN: torch-mlir-opt <%s -split-input-file -verify-diagnostics -convert-torch-onnx-to-torch
// FB OPT OPS from https://github.com/llvm/torch-mlir/issues/2689
// -----
func.func @cast_operation(%arg0: !torch.vtensor<[?,?,?,?],si64>) -> !torch.vtensor<[?,?,?,?],f32> attributes {torch.onnx_meta.ir_version = 9 : si64, torch.onnx_meta.opset_version = 18 : si64, torch.onnx_meta.producer_name = "backend-test", torch.onnx_meta.producer_version = ""} {
// expected-error @+1 {{failed to legalize operation 'torch.operator'}}
%208 = torch.operator "onnx.Cast"(%arg0) {
torch.onnx.to = 1 : si64
} : (!torch.vtensor<[?,?,?,?],si64>) -> !torch.vtensor<[?,?,?,?],f32>
return %208 : !torch.vtensor<[?,?,?,?],f32>
@renxida
renxida / TorchOps.h.inc
Created December 21, 2023 04:25
TorchOps.h.inc
This file has been truncated, but you can view the full file.
/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|* *|
|* Op Declarations *|
|* *|
|* Automatically generated file, do not edit! *|
|* From: TorchOps.td *|
|* *|
\*===----------------------------------------------------------------------===*/
#if defined(GET_OP_CLASSES) || defined(GET_OP_FWD_DEFINES)
@renxida
renxida / spawnsharkturbine.sh
Last active December 7, 2023 21:17
get the dependencies and run shark turbine
#!/bin/bash
# Xida: I tested this on a fresh GCP machine. It should work on Debian and Ubuntu though.
# deps
sudo apt install wget git -y
# Specify the Miniconda version you want to install
MINICONDA_VERSION="latest"
# For a specific version, replace 'latest' with the version number, e.g., "Miniconda3-4.7.12-Linux-x86_64.sh"
@renxida
renxida / courage.txt
Last active October 23, 2023 15:18
The Courage to be Disliked, A Discord-chat style summary by Visakan and Billy, originally posted on twitter
From @visakanv and @billyisyoung
https://twitter.com/visakanv/status/1037754098328600576?t=mwXfUbS-Mxjr-4zODZjQNw&s=19
The courage to be disliked, Ichiro Kishimi and Fumitake Koga. Heard good things, let’s dig in
Youth tells philosopher, life is hard and complicated and full of struggle. Philosopher says life is simple. Debate ensues
@renxida
renxida / tokc
Created October 19, 2023 20:07
tokc: a token counting utility
#!/usr/bin/env python
"""
tokc: A Token Counter Utility
Description:
-------------
tokc is a tool designed to count tokens in text files or input streams. It's especially useful for calculating the cost of using text with various models.
Installation:
#!/bin/bash
# Install Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
rm miniconda.sh
# Add Miniconda to PATH
export PATH="$HOME/miniconda/bin:$PATH"