Skip to content

Instantly share code, notes, and snippets.

View makslevental's full-sized avatar
💩

Maksim Levental makslevental

💩
View GitHub Profile
@makslevental
makslevental / farkas.md
Last active July 24, 2025 03:23
farkas lemma

First I'll say that whoever is telling you you need to understand farkas lemma to understand loop carried dependencies is completely fucking with you. Even the people that should understand it probably don't (I can think of 5 people in my professional circle that are "polyhedral" people and I guarantee they don't remember/don't care about farkas).

Secondly, farkas clicked for me after thinking about barrier functions and duality. Bear with me because I haven't thought about this in a while:

Ax = b 

is a linear system of constraints and you're looking for a solution right? Constrained optimization is "hard" because in principle your search algo should always satisfy the constraints.

What's easier is unconstrained optimization i.e. gradient descent. How can you (sort of) turn Ax = b into an unconstrained optimization problem? Write down a penalty function that "penalizes" for violating each of the constraints and then just use gradient descent.

This file has been truncated, but you can view the full file.
2025-07-23T18:34:50.0658280Z Current runner version: '2.326.0'
2025-07-23T18:34:50.0673920Z ##[group]Operating System
2025-07-23T18:34:50.0674530Z macOS
2025-07-23T18:34:50.0674860Z 14.7.6
2025-07-23T18:34:50.0675340Z 23H626
2025-07-23T18:34:50.0675690Z ##[endgroup]
2025-07-23T18:34:50.0676300Z ##[group]Runner Image
2025-07-23T18:34:50.0676760Z Image: macos-14-arm64
2025-07-23T18:34:50.0677100Z Version: 20250715.1663
2025-07-23T18:34:50.0677790Z Included Software: https://github.com/actions/runner-images/blob/macos-14-arm64/20250715.1663/images/macos/macos-14-arm64-Readme.md
diff --git a/mlir/include/mlir/Bindings/Python/NanobindAdaptors.h b/mlir/include/mlir/Bindings/Python/NanobindAdaptors.h
index 2dd35c097c796..8dcf91e5806bd 100644
--- a/mlir/include/mlir/Bindings/Python/NanobindAdaptors.h
+++ b/mlir/include/mlir/Bindings/Python/NanobindAdaptors.h
@@ -20,6 +20,7 @@
#define MLIR_BINDINGS_PYTHON_NANOBINDADAPTORS_H
#include <cstdint>
+#include <optional>
Index: mlir/include/mlir/Bindings/Python/NanobindAdaptors.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/mlir/include/mlir/Bindings/Python/NanobindAdaptors.h b/mlir/include/mlir/Bindings/Python/NanobindAdaptors.h
--- a/mlir/include/mlir/Bindings/Python/NanobindAdaptors.h (revision 468275dc491e88d68def668f1a23cde9ba952e5e)
+++ b/mlir/include/mlir/Bindings/Python/NanobindAdaptors.h (date 1752159288603)
@@ -43,18 +43,14 @@
/// with a raw handle (unowned). The returned object's lifetime may not extend
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Copyright (c) 2025.
[project]
name = "mlir-python-bindings"
version = "0.0.1"
requires-python = ">=3.8,<=3.13"
[project.urls]
//===--- ItaniumMangle.cpp - Itanium C++ Name Mangling ----------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Implements C++ name mangling according to the Itanium C++ ABI,
// which is used in GCC 3.2 and newer (and many compilers that are
@makslevental
makslevental / lc_cluster_soln_strats.py
Created May 30, 2025 18:21
cluster lc by soln strat
import re
import time
from collections import defaultdict
from pprint import pprint
import hdbscan
import leetcode
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.preprocessing import normalize
@makslevental
makslevental / gen.py
Last active May 12, 2025 21:57
gen conundrum
import dis
import inspect
def my_generator():
frame = inspect.currentframe()
print(frame.f_code.co_consts)
x = yield
frame = inspect.currentframe()
print(frame.f_code.co_consts)
%1085 = tail call <16 x float> @llvm.amdgcn.mfma.f32.32x32x16.f16(<8 x half> %1056, <8 x half> %1052, <16 x float> %1084, i32 0, i32 0, i32 0), !dbg !62
%1947 = shufflevector <2 x float> %1478, <2 x float> poison, <16 x i32> zeroinitializer, !dbg !62
%1948 = fmul <16 x float> %1085, %1947, !dbg !62
%1949 = tail call <16 x float> @llvm.amdgcn.mfma.f32.32x32x16.f16(<8 x half> %1931, <8 x half> %1906, <16 x float> %1948, i32 0, i32 0, i32 0), !dbg !62
/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|* *|
|* Target Register Enum Values *|
|* *|
|* Automatically generated file, do not edit! *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifdef GET_REGINFO_ENUM