This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tinygrad import Tensor, nn, Device, TinyJit | |
from tinygrad.nn.datasets import mnist | |
from tinygrad.nn.state import safe_save, get_state_dict | |
import math | |
print(f"Using device: {Device.DEFAULT}") | |
# normalization for Pattention | |
def nonlinear_normalization(inputs, normalization_type, dim=-1): | |
if normalization_type == 'softmax': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import struct | |
def send_message(writer, message): | |
data = message.encode() | |
size = struct.pack('>L', len(data)) | |
writer.write(size + data) | |
async def receive_message(reader): | |
data = await reader.readexactly(4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PLATFORMPATH="/Applications/Xcode.app/Contents/Developer/Platforms" | |
TOOLSPATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin" | |
export IPHONEOS_DEPLOYMENT_TARGET="8.0" | |
pwd=`pwd` | |
findLatestSDKVersion() | |
{ | |
sdks=`ls $PLATFORMPATH/$1.platform/Developer/SDKs` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct node { | |
int val; | |
struct node *next; | |
} node_t; | |
void enqueue(node_t **head, int val) { | |
node_t *new_node = malloc(sizeof(node_t)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include "sqlite3.h" | |
int save_binary_file(char *file_path, void *buffer, int size) { | |
FILE *fp; | |
fp = fopen(file_path, "wb"); | |
if (fp) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOCAL_PATH := $(call my-dir)/nanomsg | |
include $(CLEAR_VARS) | |
LOCAL_SRC_FILES := src/core/epbase.c src/core/sock.c src/core/poll.c \ | |
src/core/symbol.c src/core/ep.c src/core/pipe.c \ | |
src/core/sockbase.c src/core/global.c src/devices/device.c \ | |
src/transports/inproc/ins.c src/transports/inproc/inproc.c \ | |
src/transports/inproc/cinproc.c src/transports/inproc/binproc.c \ | |
src/transports/inproc/sinproc.c src/transports/inproc/msgqueue.c \ |