text stringlengths 24 1.04M | metadata stringlengths 233 497 |
|---|---|
### File: misc/baselines/gpu_memory_bound.cu
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cuda_runtime.h>
#include "get_time.h"
__global__ void cpy(float *a, float *b, int n) {
unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n)
a[i] = b[i];
}
int main() {
int n = 1024 *... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Cuda", "repo_name": "minhanghuang/Taichi", "path": "misc/baselines/gpu_memory_bound.cu", "license": "mit", "size": 1157} |
### File: misc/baselines/gpu_reduction.cu
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cuda_runtime.h>
#include "get_time.h"
__inline__ __device__ int warpReduceSum(int val) {
for (int offset = warpSize / 2; offset > 0; offset /= 2)
val += __shfl_down_sync(val, offset, 0xFFFFFFFF);
return... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Cuda", "repo_name": "minhanghuang/Taichi", "path": "misc/baselines/gpu_reduction.cu", "license": "mit", "size": 1441} |
### File: misc/baselines/kernel_malloc.cu
#include "cuda_runtime.h"
#include <cstdio>
#include "time.h"
constexpr int segment_size = 1024;
constexpr int threads = 512;
__device__ char *pool;
void __global__ alloc(int **pointers) {
auto index = blockIdx.x * blockDim.x + threadIdx.x;
// pointers[index] = (int *)mal... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Cuda", "repo_name": "minhanghuang/Taichi", "path": "misc/baselines/kernel_malloc.cu", "license": "mit", "size": 1106} |
### File: misc/baselines/laplace.cu
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cuda_runtime.h>
#include <cmath>
#include "get_time.h"
constexpr int N = 4096;
constexpr int bs = 16;
__global__ void fill(float *a) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDi... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Cuda", "repo_name": "minhanghuang/Taichi", "path": "misc/baselines/laplace.cu", "license": "mit", "size": 3092} |
### File: misc/baselines/ldg.cu
// Compile this file with clang to see how CUDA
// is translated into NVVM IR.
__device__ int cube(int x) {
int y;
asm(".reg .u32 t1;\n\t" // temp reg t1
" mul.lo.u32 t1, %1, %1;\n\t" // t1 = x * x
" mul.lo.u32 %0, t1, %1;" // y = t1 * x
: "=r"(y)
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Cuda", "repo_name": "minhanghuang/Taichi", "path": "misc/baselines/ldg.cu", "license": "mit", "size": 745} |
### File: misc/baselines/mutex.cu
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cuda_runtime.h>
#include <sys/time.h>
double get_time() {
struct timeval tv;
gettimeofday(&tv, nullptr);
return tv.tv_sec + 1e-6 * tv.tv_usec;
}
constexpr int m = 2;
constexpr int block_size = 128;
struct Node ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Cuda", "repo_name": "minhanghuang/Taichi", "path": "misc/baselines/mutex.cu", "license": "mit", "size": 3812} |
### File: misc/baselines/rand.cu
#include <curand.h>
#include <curand_kernel.h>
#include <cuda_runtime.h>
#include <cstdio>
constexpr int num_states = 1024 * 1024;
__device__ curandState_t states[num_states];
// https://cs.calvin.edu/courses/cs/374/CUDA/CUDA-Thread-Indexing-Cheatsheet.pdf
__global__ void init_random_... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Cuda", "repo_name": "minhanghuang/Taichi", "path": "misc/baselines/rand.cu", "license": "mit", "size": 1260} |
### File: misc/benchmark_bit_struct_stores.py
import taichi as ti
ti.init(arch=ti.cpu, kernel_profiler=True, print_ir=True)
quant = True
n = 1024 * 1024 * 256
if quant:
ci16 = ti.quant.int(16, True)
x = ti.field(dtype=ci16)
y = ti.field(dtype=ci16)
ti.root.dense(ti.i, n).bit_struct(num_bits=32).pl... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/benchmark_bit_struct_stores.py", "license": "mit", "size": 545} |
### File: misc/benchmark_bls.py
import sys
import taichi as ti
sys.path.append('../tests/python/')
from bls_test_template import bls_test_template
ti.init(arch=ti.gpu,
print_ir=True,
kernel_profiler=True,
demote_dense_struct_fors=False)
stencil = [(0, 0), (0, -1), (0, 1), (-1, 0), (1, 0)]
b... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/benchmark_bls.py", "license": "mit", "size": 489} |
### File: misc/benchmark_compile.py
import autograd.numpy as np
from autograd import grad
from pytest import approx
import taichi as ti
@ti.all_archs
def grad_test(tifunc, npfunc=None):
if npfunc is None:
npfunc = tifunc
x = ti.field(ti.f32)
y = ti.field(ti.f32)
ti.root.dense(ti.i, 1).place... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/benchmark_compile.py", "license": "mit", "size": 879} |
### File: misc/benchmark_parallel_compilation.py
# This file has a kernel with 16 equal offloaded tasks.
import taichi as ti
ti.init(arch=ti.x64)
quality = 1 # Use a larger value for higher-res simulations
n_particles, n_grid = 9000 * quality**2, 128 * quality
dx, inv_dx = 1 / n_grid, float(n_grid)
dt = 1e-4 / quali... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/benchmark_parallel_compilation.py", "license": "mit", "size": 2836} |
### File: misc/benchmark_rebuild_graph.py
import taichi as ti
ti.init(arch=ti.cuda, async_mode=True)
a = ti.field(dtype=ti.i32, shape=())
b = ti.field(dtype=ti.i32, shape=())
c = ti.field(dtype=ti.i32, shape=())
d = ti.field(dtype=ti.i32, shape=())
e = ti.field(dtype=ti.i32, shape=())
f = ti.field(dtype=ti.i32, shape... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/benchmark_rebuild_graph.py", "license": "mit", "size": 492} |
### File: misc/benchmark_reduction.py
import taichi as ti
# TODO: make this a real benchmark and set up regression
ti.init(arch=ti.gpu)
N = 1024 * 1024 * 1024
a = ti.field(ti.i32, shape=N)
tot = ti.field(ti.i32, shape=())
@ti.kernel
def fill():
ti.block_dim(128)
for i in a:
a[i] = i
@ti.kernel
d... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/benchmark_reduction.py", "license": "mit", "size": 523} |
### File: misc/benchmark_reduction_tmps.py
import time
from pytest import approx
import taichi as ti
# TODO: make this a real benchmark and set up regression
# TODO: merge this file into benchmark_reduction.py
ti.init(arch=ti.gpu,
print_ir=True,
print_kernel_llvm_ir=True,
kernel_profiler=True... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/benchmark_reduction_tmps.py", "license": "mit", "size": 913} |
### File: misc/benchmark_scatter_bls.py
import sys
import taichi as ti
sys.path.append('../tests/python/')
from bls_test_template import bls_particle_grid
ti.init(arch=ti.cuda, kernel_profiler=True)
bls_particle_grid(N=512,
ppc=10,
block_size=16,
scatter=True,
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/benchmark_scatter_bls.py", "license": "mit", "size": 409} |
### File: misc/benchmark_tensor_access.py
import ctypes
import math
import time
import taichi as ti
libm = ctypes.CDLL('libm.so.6')
x, y = ti.field(ti.f32), ti.field(ti.f32)
@ti.kernel
def laplace():
for i, j in x:
y[i,
j] = 4.0 * x[i, j] - x[i - 1, j] - x[i + 1,
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/benchmark_tensor_access.py", "license": "mit", "size": 870} |
### File: misc/ci_check_pr_title.py
import json
import os
import sys
import git
import semver
def get_old_ver():
repo = git.Repo('.')
for c in repo.iter_commits('master', max_count=200):
if c.summary.startswith('[release]'):
ver = c.summary.split(']', maxsplit=1)[1]
if ver[0] ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/ci_check_pr_title.py", "license": "mit", "size": 2656} |
### File: misc/ci_check_previous_run.py
import argparse
import json
import logging
import sys
import time
import urllib.request as ur
API_PREFIX = 'https://api.github.com/repos/taichi-dev/taichi'
SHA = 'sha'
OAUTH_TOKEN = None
def make_api_url(p):
return f'{API_PREFIX}/{p}'
def send_request(url):
# https:/... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/ci_check_previous_run.py", "license": "mit", "size": 6019} |
### File: misc/ci_download.py
import os
platform = os.environ['CI_PLATFORM']
if platform.startswith('macos'):
platform = 'macos'
elif platform.startswith('ubuntu'):
platform = 'linux'
elif platform.startswith('windows'):
platform = 'msvc2019'
else:
raise Exception(f'Bad CI_PLATFORM={platform}')
llvm_u... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/ci_download.py", "license": "mit", "size": 520} |
### File: misc/ci_setup.py
print("* Taichi Installer")
import os
import platform
import subprocess
import sys
from os import environ
print(platform.architecture())
build_type = 'default'
# Utils
import struct
assert struct.calcsize(
'P'
) * 8 == 64, "Only 64-bit platforms are supported. Current platform: {}".f... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/ci_setup.py", "license": "mit", "size": 8544} |
### File: misc/copyright.py
#!/usr/bin/env python3
# Copyright (c) 2020 The Taichi Authors. All rights reserved.
# Use of this software is governed by the LICENSE file.
"""
Open each source file and add a copyright notice if it is missing.
Could be faster with multiprocessing or async/await but this is
just an one-off ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/copyright.py", "license": "mit", "size": 11900} |
### File: misc/count_tags.py
import os
import sys
from git import Repo
commits = list(Repo('.').iter_commits('master'))
authors = {}
notable = {}
changelog = {}
for i, c in enumerate(commits):
s = c.summary
tags = []
while s[0] == '[':
r = s.find(']')
tag = s[1:r]
tags.append(ta... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/count_tags.py", "license": "mit", "size": 1018} |
### File: misc/demo_constant_fold.py
# https://github.com/taichi-dev/taichi/pull/839#issuecomment-626217806
import taichi as ti
ti.init(print_ir=True)
#ti.core.toggle_advanced_optimization(False)
@ti.kernel
def calc_pi() -> ti.f32:
term = 1.0
sum = 0.0
divisor = 1
for i in ti.static(range(10)):
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/demo_constant_fold.py", "license": "mit", "size": 402} |
### File: misc/demo_excepthook.py
import taichi as ti
ti.init()
ti.enable_excepthook()
@ti.func
def func3():
ti.static_assert(1 + 1 == 3)
@ti.func
def func2():
func3()
@ti.func
def func1():
func2()
@ti.kernel
def func0():
func1()
func0()
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/demo_excepthook.py", "license": "mit", "size": 231} |
### File: misc/demo_external_func.py
import ctypes
import os
import taichi as ti
ti.init()
N = 1024
x = ti.field(ti.i32, shape=N)
y = ti.field(ti.i32, shape=N)
z = ti.field(ti.i32, shape=N)
source = '''
extern "C" {
void add_and_mul(float a, float b, float *c, float *d, int *e) {
*c = a + b;
*d ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/demo_external_func.py", "license": "mit", "size": 1407} |
### File: misc/demo_launch_overhead.py
import time
import taichi as ti
ti.init()
@ti.kernel
def compute_div(a: ti.i32):
pass
compute_div(0)
print("starting...")
t = time.time()
for i in range(100000):
compute_div(0)
print((time.time() - t) * 10, 'us')
exit(0)
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/demo_launch_overhead.py", "license": "mit", "size": 235} |
### File: misc/demo_listgen.py
import taichi as ti
ti.init(print_ir=True)
x = ti.field(ti.i32)
ti.root.dense(ti.i, 4).bitmasked(ti.i, 4).place(x)
@ti.kernel
def func():
for i in x:
print(i)
func()
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/demo_listgen.py", "license": "mit", "size": 184} |
### File: misc/demo_oob_ub.py
# https://forum.taichi.graphics/t/taichi/1003
import taichi as ti
ti.init(arch=ti.cpu)
N = 3
x = ti.field(ti.i32, N)
@ti.kernel
def test():
for i in x:
x[i] = 1000 + i
for i in ti.static(range(-N, 2 * N)):
print(i, x[i])
test()
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/demo_oob_ub.py", "license": "mit", "size": 259} |
### File: misc/demo_record_kernel_group.py
import taichi as ti
ti.start_recording('record.yml')
ti.init(arch=ti.cc)
loss = ti.field(float, (), needs_grad=True)
x = ti.field(float, 233, needs_grad=True)
@ti.kernel
def compute_loss():
for i in x:
loss[None] += x[i]**2
@ti.kernel
def do_some_works():
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/demo_record_kernel_group.py", "license": "mit", "size": 440} |
### File: misc/demo_warning.py
import taichi as ti
x = ti.Vector([2, 3])
x.transposed(x)
@ti.kernel
def func():
x = 0
x = 0.1
func()
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/demo_warning.py", "license": "mit", "size": 116} |
### File: misc/fetch_active_contributors.py
import requests
def print_active_contributors():
api_prefix = 'https://api.github.com/repos/taichi-dev/taichi'
per_page = 100
contributors = []
page = 1
while True:
contributors_json = requests.get(
f'{api_prefix}/contributors?per_p... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/fetch_active_contributors.py", "license": "mit", "size": 1631} |
### File: misc/format_server.py
import argparse
import subprocess
from http.server import BaseHTTPRequestHandler, HTTPServer
import requests
# TODO: remove these globals?
server_addr, server_port = None, None
class TaichiFormatServer(BaseHTTPRequestHandler):
def _set_headers(self):
self.send_response(20... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/format_server.py", "license": "mit", "size": 4088} |
### File: misc/generate_commit_hash.py
import os
from git import Repo
repo_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../')
repo = Repo(repo_dir)
commit_hash = str(repo.head.commit)
print(f"Building commit {commit_hash}")
output_fn = os.path.join(repo_dir, 'taichi/common/commit_hash.h')
content ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/generate_commit_hash.py", "license": "mit", "size": 668} |
### File: misc/generate_ir_design_doc.py
import os
import yaml
import taichi as ti
def extract_doc(doc_filename=None):
repo_dir = ti.get_repo_directory()
statements_fn = os.path.join(repo_dir, 'taichi/ir/statements.h')
with open(statements_fn, 'r') as f:
statements = f.readlines()
class_doc... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/generate_ir_design_doc.py", "license": "mit", "size": 2275} |
### File: misc/idle_hello.py
import taichi as ti
@ti.kernel
def func():
pass
func()
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/idle_hello.py", "license": "mit", "size": 63} |
### File: misc/minimal_timed.py
import time
import taichi as ti
t = time.time()
ti.init(arch=ti.cuda, print_kernel_llvm_ir_optimized=True)
@ti.kernel
def p():
print(42)
p()
print(f'{time.time() - t:.3f} s')
ti.core.print_profile_info()
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/minimal_timed.py", "license": "mit", "size": 215} |
### File: misc/visualize_quant_types.py
import argparse
import math
import os
from struct import pack, unpack
import taichi as ti
ti.init()
f19 = ti.quant.float(exp=6, frac=13, signed=True)
f16 = ti.quant.float(exp=5, frac=11, signed=True)
fixed16 = ti.quant.fixed(frac=16, range=2)
vf19 = ti.Vector.field(2, dtype=f... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/visualize_quant_types.py", "license": "mit", "size": 4263} |
### File: misc/visualize_state_flow_graph.py
import taichi as ti
def test_fusion_range():
ti.init(arch=ti.cpu,
async_mode=True,
async_opt_fusion=False,
async_opt_intermediate_file="fusion_range")
x = ti.field(ti.i32)
y = ti.field(ti.i32)
z = ti.field(ti.i32)
n... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/visualize_state_flow_graph.py", "license": "mit", "size": 2799} |
### File: misc/windows_build.py
import os
import shutil
import sys
def execute_cmd(cmd):
print('Executing', resolve_env(cmd))
return os.system(cmd)
def resolve_env(v):
# replace `%`
modified = True
while modified:
modified = False
for i in range(len(v)):
if v[i] == '%... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "misc/windows_build.py", "license": "mit", "size": 2106} |
### File: python/build.py
import argparse
import os
import platform
import shutil
import sys
import taichi as ti
def get_os_name():
name = platform.platform()
# in python 3.8, platform.platform() uses mac_ver() on macOS
# it will return 'macOS-XXXX' instead of 'Darwin-XXXX'
if name.lower().startswith... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/build.py", "license": "mit", "size": 6488} |
### File: python/make_release.py
import os
import shutil
import zipfile
import requests
projects = ['nightly', 'nightly-cuda-10-0', 'nightly-cuda-10-1']
def download(url):
fn = url.split('/')[-1]
with requests.get(url, stream=True) as r:
with open(fn, 'wb') as f:
shutil.copyfileobj(r.raw... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/make_release.py", "license": "mit", "size": 1198} |
### File: python/taichi/__init__.py
from .core import *
from .lang import * # TODO(archibate): It's `taichi.lang.core` overriding `taichi.core`
from .main import main
from .misc import *
from .testing import *
from .tools import *
from .torch_io import from_torch, to_torch
__all__ = ['core', 'misc', 'lang', 'tools', ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/__init__.py", "license": "mit", "size": 413} |
### File: python/taichi/__main__.py
from .main import main
main()
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/__main__.py", "license": "mit", "size": 31} |
### File: python/taichi/cc_compose.py
import sys
import warnings
import yaml
class ComposerBase:
def __init__(self, entries):
self.entries = entries
self.current_group = None
self.groups = {}
self.launches = []
def run(self):
for e in self.entries:
action ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/cc_compose.py", "license": "mit", "size": 4168} |
### File: python/taichi/code_format.py
#!/usr/bin/python3
import os
import re
import subprocess as sp
import sys
from pathlib import Path
from colorama import Back, Fore, Style
from git import Repo
from yapf.yapflib.yapf_api import FormatFile
_has_isort = False
try:
import isort
_has_isort = True
except Impo... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/code_format.py", "license": "mit", "size": 4738} |
### File: python/taichi/core/__init__.py
from taichi.core.logging import *
from taichi.core.primitive_types import *
from taichi.core.record import *
from taichi.core.settings import *
from taichi.core.util import *
ti_core.build = build
ti_core.load_module = load_module
__all__ = [s for s in dir() if not s.startswit... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/core/__init__.py", "license": "mit", "size": 287} |
### File: python/taichi/core/logging.py
import inspect
import os
from taichi.core import util
def get_logging(name):
def logger(msg, *args, **kwargs):
# Python inspection takes time (~0.1ms) so avoid it as much as possible
if util.ti_core.logging_effective(name):
msg_formatted = msg.f... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/core/logging.py", "license": "mit", "size": 1191} |
### File: python/taichi/core/primitive_types.py
from taichi.core.util import ti_core as _ti_core
# Real types
float32 = _ti_core.DataType_f32
f32 = float32
float64 = _ti_core.DataType_f64
f64 = float64
real_types = [f32, f64, float]
real_type_ids = [id(t) for t in real_types]
# Integer types
int8 = _ti_core.DataTy... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/core/primitive_types.py", "license": "mit", "size": 1027} |
### File: python/taichi/core/record.py
import os
from taichi.core import util
def record_action_entry(name, contents):
util.ti_core.record_action_entry(name, list(contents.items()))
def record_action_hint(name, content=None):
if content is None:
name, content = 'hint', name
record_action_entry(... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/core/record.py", "license": "mit", "size": 1318} |
### File: python/taichi/core/settings.py
import multiprocessing
import os
import platform
def get_num_cores():
default_num_threads = multiprocessing.cpu_count()
return os.environ.get('TAICHI_NUM_THREADS', default_num_threads)
def get_os_name():
name = platform.platform()
# in python 3.8, platform.pl... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/core/settings.py", "license": "mit", "size": 2663} |
### File: python/taichi/core/util.py
import ctypes
import os
import re
import shutil
import sys
from pathlib import Path
from colorama import Back, Fore, Style
from .settings import *
if sys.version_info[0] < 3 or sys.version_info[1] <= 5:
raise RuntimeError(
"\nPlease restart with Python 3.6+\n" + "Curr... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/core/util.py", "license": "mit", "size": 12096} |
### File: python/taichi/diagnose.py
def main():
print('Taichi system diagnose:')
print('')
import locale
import os
import platform
import subprocess
import sys
executable = sys.executable
print(f'python: {sys.version}')
print(f'system: {sys.platform}')
print(f'executable: ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/diagnose.py", "license": "mit", "size": 3754} |
### File: python/taichi/lang/__init__.py
import functools
import os
from copy import deepcopy as _deepcopy
from taichi.core.util import ti_core as _ti_core
from taichi.lang import impl
from taichi.lang.impl import *
from taichi.lang.kernel_arguments import ext_arr, template
from taichi.lang.kernel_impl import (KernelA... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/__init__.py", "license": "mit", "size": 25425} |
### File: python/taichi/lang/ast_checker.py
import ast
from taichi.lang.shell import oinspect
class KernelSimplicityASTChecker(ast.NodeVisitor):
class ScopeGuard:
def __init__(self, checker):
self.c = checker
self._allows_for_loop = True
self._allows_more_stmt = True
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/ast_checker.py", "license": "mit", "size": 3686} |
### File: python/taichi/lang/ast_resolver.py
"""Provides helpers to resolve AST nodes."""
import ast
class ASTResolver:
"""Provides helper methods to resolve AST nodes."""
@staticmethod
def resolve_to(node, wanted, scope):
"""Check if symbol ``node`` resolves to ``wanted`` object.
This is... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/ast_resolver.py", "license": "mit", "size": 1754} |
### File: python/taichi/lang/common_ops.py
import taichi as ti
class TaichiOperations:
def __neg__(self):
_taichi_skip_traceback = 1
return ti.neg(self)
def __abs__(self):
_taichi_skip_traceback = 1
return ti.abs(self)
def __add__(self, other):
_taichi_skip_traceb... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/common_ops.py", "license": "mit", "size": 6804} |
### File: python/taichi/lang/exception.py
class TaichiSyntaxError(Exception):
def __init__(self, *args):
super().__init__(*args)
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/exception.py", "license": "mit", "size": 99} |
### File: python/taichi/lang/expr.py
from taichi.core.util import ti_core as _ti_core
from taichi.lang import impl
from taichi.lang.common_ops import TaichiOperations
from taichi.lang.util import (is_taichi_class, python_scope, to_numpy_type,
to_pytorch_type)
from taichi.misc.util import d... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/expr.py", "license": "mit", "size": 7329} |
### File: python/taichi/lang/impl.py
import numbers
import types
import warnings
import numpy as np
from taichi.core.util import ti_core as _ti_core
from taichi.lang.exception import TaichiSyntaxError
from taichi.lang.expr import Expr, make_expr_group
from taichi.lang.snode import SNode
from taichi.lang.tape import Ta... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/impl.py", "license": "mit", "size": 17751} |
### File: python/taichi/lang/kernel_arguments.py
from taichi.core.util import ti_core as _ti_core
from taichi.lang.expr import Expr
from taichi.lang.snode import SNode
from taichi.lang.util import cook_dtype, to_taichi_type
class ArgExtArray:
def __init__(self, dim=1):
assert dim == 1
def extract(sel... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/kernel_arguments.py", "license": "mit", "size": 1308} |
### File: python/taichi/lang/kernel_impl.py
import ast
import copy
import functools
import inspect
import re
import numpy as np
from taichi.core import primitive_types
from taichi.core.util import ti_core as _ti_core
from taichi.lang import impl, util
from taichi.lang.ast_checker import KernelSimplicityASTChecker
from... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/kernel_impl.py", "license": "mit", "size": 23916} |
### File: python/taichi/lang/linalg.py
from taichi.core.util import ti_core as _ti_core
from taichi.lang.impl import expr_init
import taichi as ti
@ti.func
def polar_decompose2d(a, dt):
x, y = a(0, 0) + a(1, 1), a(1, 0) - a(0, 1)
scale = (1.0 / ti.sqrt(x * x + y * y))
c = x * scale
s = y * scale
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/linalg.py", "license": "mit", "size": 2840} |
### File: python/taichi/lang/matrix.py
import copy
import numbers
from collections.abc import Iterable
import numpy as np
from taichi.lang import expr, impl
from taichi.lang import kernel_impl as kern_mod
from taichi.lang import ops as ops_mod
from taichi.lang.common_ops import TaichiOperations
from taichi.lang.except... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/matrix.py", "license": "mit", "size": 34396} |
### File: python/taichi/lang/meta.py
from taichi.core import settings
from taichi.lang import impl
from taichi.lang.expr import Expr
import taichi as ti
# A set of helper (meta)functions
@ti.kernel
def fill_tensor(tensor: ti.template(), val: ti.template()):
for I in ti.grouped(tensor):
tensor[I] = val
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/meta.py", "license": "mit", "size": 3888} |
### File: python/taichi/lang/ndrange.py
import taichi as ti
class ndrange:
def __init__(self, *args):
args = list(args)
for i in range(len(args)):
if isinstance(args[i], list):
args[i] = tuple(args[i])
if not isinstance(args[i], tuple):
args[... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/ndrange.py", "license": "mit", "size": 1407} |
### File: python/taichi/lang/ops.py
import builtins
import ctypes
import functools
import math
import operator as _bt_ops_mod # bt for builtin
import traceback
from taichi.core.util import ti_core as _ti_core
from taichi.lang import impl
from taichi.lang.exception import TaichiSyntaxError
from taichi.lang.expr import... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/ops.py", "license": "mit", "size": 12406} |
### File: python/taichi/lang/quant_impl.py
from taichi.lang import impl
from taichi.lang import type_factory_impl as tf_impl
import taichi as ti
class Quant:
@staticmethod
def int(bits, signed=False, compute=None):
if compute is None:
compute = impl.get_runtime().default_ip
return... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/quant_impl.py", "license": "mit", "size": 1476} |
### File: python/taichi/lang/runtime_ops.py
from taichi.lang import impl
def sync():
impl.get_runtime().sync()
def async_flush():
impl.get_runtime().prog.async_flush()
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/runtime_ops.py", "license": "mit", "size": 136} |
### File: python/taichi/lang/shell.py
import atexit
import functools
import os
import sys
from taichi.core.util import ti_core as _ti_core
import taichi as ti
try:
import sourceinspect as oinspect
except ImportError:
ti.warn('`sourceinspect` not installed!')
ti.warn(
'Without this package Taichi ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/shell.py", "license": "mit", "size": 1472} |
### File: python/taichi/lang/snode.py
import numbers
# The reason we import just the taichi.core.util module, instead of the ti_core
# object within it, is that ti_core is stateful. While in practice ti_core is
# loaded during the import procedure, it's probably still good to delay the
# access to it.
from taichi.core... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/snode.py", "license": "mit", "size": 6329} |
### File: python/taichi/lang/tape.py
class TapeImpl:
def __init__(self, runtime, loss=None):
self.calls = []
self.entered = False
self.gradient_evaluated = False
self.runtime = runtime
self.eval_on_exit = loss is not None
def __enter__(self):
self.runtime.target_... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/tape.py", "license": "mit", "size": 979} |
### File: python/taichi/lang/transformer.py
import ast
import copy
from taichi.lang import impl
from taichi.lang.ast_resolver import ASTResolver
from taichi.lang.exception import TaichiSyntaxError
from taichi.lang.util import to_taichi_type
import taichi as ti
class ScopeGuard:
def __init__(self, scopes, stmt_b... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/transformer.py", "license": "mit", "size": 34298} |
### File: python/taichi/lang/type_factory_impl.py
from taichi.core.util import ti_core as _ti_core
from taichi.lang import impl
class TypeFactory:
def __init__(self):
self.core = _ti_core.get_type_factory_instance()
def custom_int(self, bits, signed=True, compute_type=None):
if compute_type i... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/type_factory_impl.py", "license": "mit", "size": 1185} |
### File: python/taichi/lang/util.py
import functools
import os
import numpy as np
from taichi.core.util import ti_core as _ti_core
from taichi.lang import impl
import taichi as ti
_has_pytorch = False
_env_torch = os.environ.get('TI_ENABLE_TORCH', '1')
if not _env_torch or int(_env_torch):
try:
import ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/lang/util.py", "license": "mit", "size": 3955} |
### File: python/taichi/main.py
import argparse
import math
import os
import random
import runpy
import shutil
import sys
import time
from collections import defaultdict
from functools import wraps
from pathlib import Path
from colorama import Back, Fore, Style
from taichi.core import ti_core as _ti_core
from taichi.t... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/main.py", "license": "mit", "size": 40615} |
### File: python/taichi/make_changelog.py
# Usage: make_changelog.py [v0.x.y]
import json
import os
import sys
from git import Repo
def load_pr_tags():
this_dir = os.path.dirname(os.path.abspath(__file__))
json_path = os.path.join(this_dir, '../../misc/prtags.json')
details = {}
with open(json_path)... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/make_changelog.py", "license": "mit", "size": 2137} |
### File: python/taichi/misc/__init__.py
from .error import *
from .gui import *
from .image import *
from .task import Task
from .util import *
__all__ = [s for s in dir() if not s.startswith('_')]
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/misc/__init__.py", "license": "mit", "size": 159} |
### File: python/taichi/misc/error.py
import functools
import sys
import traceback
from colorama import Fore, Style
def enable_excepthook():
def excepthook(exctype, value, tb):
skip = 0
back = 4
forward = 2
bar = f'{Fore.LIGHTBLACK_EX}{"-"*44}{Fore.RESET}'
print(
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/misc/error.py", "license": "mit", "size": 1832} |
### File: python/taichi/misc/gui.py
import numbers
import os
import numpy as np
from taichi.core import ti_core as _ti_core
from .util import core_veci, deprecated
class GUI:
class Event:
pass
# Event keys
SHIFT = 'Shift'
ALT = 'Alt'
CTRL = 'Control'
ESCAPE = 'Escape'
RETURN = '... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/misc/gui.py", "license": "mit", "size": 18220} |
### File: python/taichi/misc/image.py
import numpy as np
from taichi.core import ti_core as _ti_core
import taichi as ti
def cook_image_to_bytes(img):
"""
Takes a NumPy array or Taichi field of any type.
Returns a NumPy array of uint8.
This is used by ti.imwrite and ti.imdisplay.
"""
if not i... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/misc/image.py", "license": "mit", "size": 3427} |
### File: python/taichi/misc/task.py
from taichi.core import ti_core as _ti_core
from taichi.misc.util import config_from_dict
def _unit(unit_name):
def decorator(target_class):
if target_class.__init__ != object.__init__:
original_init = target_class.__init__
else:
def du... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/misc/task.py", "license": "mit", "size": 911} |
### File: python/taichi/misc/util.py
import copy
import inspect
import sys
import traceback
from colorama import Fore, Style
from taichi.core import ti_core as _ti_core
import taichi
def config_from_dict(args):
d = copy.copy(args)
for k in d:
if isinstance(d[k], _ti_core.Vector2f):
d[k] ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/misc/util.py", "license": "mit", "size": 6770} |
### File: python/taichi/testing.py
from taichi.core import ti_core as _ti_core
import taichi as ti
# Helper functions
def get_rel_eps():
arch = ti.cfg.arch
if arch == ti.opengl:
return 1e-3
elif arch == ti.metal:
# Debatable, different hardware could yield different precisions
# O... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/testing.py", "license": "mit", "size": 3387} |
### File: python/taichi/tools/__init__.py
from .np2ply import PLYWriter
from .patterns import taichi_logo
from .video import VideoManager
__all__ = [s for s in dir() if not s.startswith('_')]
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/tools/__init__.py", "license": "mit", "size": 151} |
### File: python/taichi/tools/file.py
import os
def clear_directory_with_suffix(directory, suffix):
files = os.listdir(directory)
assert suffix[0] != '.', "No '.' needed."
for f in files:
if f.endswith('.' + suffix):
os.remove(os.path.join(directory, f))
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/tools/file.py", "license": "mit", "size": 251} |
### File: python/taichi/tools/messenger.py
import atexit
import os
import smtplib
import socket
import taichi as tc
gmail_sender = 'taichi.messager@gmail.com'
gmail_passwd = '6:L+XbNOp^'
emailed = False
def send_crash_report(message, receiver=None):
global emailed
if emailed:
return
emailed = T... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/tools/messenger.py", "license": "mit", "size": 2186} |
### File: python/taichi/tools/np2ply.py
# convert numpy array to ply files
import sys
import numpy as np
import taichi as ti
class PLYWriter:
def __init__(self,
num_vertices: int,
num_faces=0,
face_type="tri",
comment="created by PLYWriter"):
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/tools/np2ply.py", "license": "mit", "size": 12462} |
### File: python/taichi/tools/patterns.py
import taichi as ti
@ti.func
def _inside(p, c, r):
return (p - c).norm_sqr() <= r * r
@ti.func
def taichi_logo(pos, scale=1 / 1.11):
p = (pos - 0.5) / scale + 0.5
ret = -1
if not (p - 0.50).norm_sqr() <= 0.52**2:
if ret == -1:
ret = 0
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/tools/patterns.py", "license": "mit", "size": 903} |
### File: python/taichi/tools/video.py
import os
from taichi.core.settings import get_os_name
from taichi.misc.image import imwrite
FRAME_FN_TEMPLATE = '%06d.png'
FRAME_DIR = 'frames'
# Write the frames to the disk and then make videos (mp4 or gif) if necessary
def scale_video(input, output, ratiow, ratioh):
o... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/tools/video.py", "license": "mit", "size": 7086} |
### File: python/taichi/torch_io.py
import taichi as ti
@ti.kernel
def from_torch_template(expr: ti.template(), torch_tensor: ti.ext_arr()):
for i in expr:
expr[i] = torch_tensor[i]
@ti.kernel
def to_torch_template(expr: ti.template(), torch_tensor: ti.ext_arr()):
for i in expr:
torch_tensor... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "python/taichi/torch_io.py", "license": "mit", "size": 650} |
### File: python/ti.cpp
#include <cstdio>
#include <cstdlib>
#include <string>
#include <Python.h>
#include "taichi/platform/windows/windows.h"
#include <iostream>
#include <vector>
#include <string>
void main(int argc, char **argv) {
Py_SetProgramName(L"ti");
Py_Initialize();
std::vector<std::wstring> argv_con... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/Taichi", "path": "python/ti.cpp", "license": "mit", "size": 1142} |
### File: setup.py
import glob
import setuptools
classifiers = [
'Development Status :: 2 - Pre-Alpha',
'Topic :: Software Development :: Compilers',
'Topic :: Multimedia :: Graphics',
'Topic :: Games/Entertainment :: Simulation',
'Intended Audience :: Science/Research',
'Intended Audience :: ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/Taichi", "path": "setup.py", "license": "mit", "size": 1690} |
### File: taichi/analysis/alias_analysis.cpp
#include "taichi/ir/ir.h"
#include "taichi/ir/analysis.h"
#include "taichi/ir/statements.h"
TLANG_NAMESPACE_BEGIN
namespace irpass::analysis {
AliasResult alias_analysis(Stmt *var1, Stmt *var2) {
// If both stmts are allocas, they have the same address iff var1 == var2.... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/Taichi", "path": "taichi/analysis/alias_analysis.cpp", "license": "mit", "size": 4431} |
### File: taichi/analysis/build_cfg.cpp
#include "taichi/ir/control_flow_graph.h"
#include "taichi/ir/ir.h"
#include "taichi/ir/statements.h"
TLANG_NAMESPACE_BEGIN
// Build a control-flow graph
class CFGBuilder : public IRVisitor {
private:
std::unique_ptr<ControlFlowGraph> graph;
Block *current_block;
CFGNode... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/Taichi", "path": "taichi/analysis/build_cfg.cpp", "license": "mit", "size": 7824} |
### File: taichi/analysis/cfg_analysis.cpp
#include "taichi/ir/analysis.h"
#include "taichi/ir/control_flow_graph.h"
#include "taichi/program/async_utils.h"
#include "taichi/program/ir_bank.h"
TLANG_NAMESPACE_BEGIN
namespace irpass::analysis {
void get_meta_input_value_states(IRNode *root,
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/Taichi", "path": "taichi/analysis/cfg_analysis.cpp", "license": "mit", "size": 624} |
### File: taichi/analysis/check_fields_registered.cpp
#include "taichi/ir/ir.h"
#include "taichi/ir/analysis.h"
#include "taichi/ir/visitors.h"
TLANG_NAMESPACE_BEGIN
class FieldsRegisteredChecker : public BasicStmtVisitor {
public:
using BasicStmtVisitor::visit;
FieldsRegisteredChecker() {
allow_undefined_v... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/Taichi", "path": "taichi/analysis/check_fields_registered.cpp", "license": "mit", "size": 785} |
### File: taichi/analysis/clone.cpp
#include "taichi/ir/ir.h"
#include "taichi/ir/analysis.h"
#include "taichi/ir/statements.h"
#include "taichi/ir/transforms.h"
#include "taichi/ir/visitors.h"
#include "taichi/program/program.h"
#include <unordered_map>
TLANG_NAMESPACE_BEGIN
class IRCloner : public IRVisitor {
pri... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/Taichi", "path": "taichi/analysis/clone.cpp", "license": "mit", "size": 4007} |
### File: taichi/analysis/constexpr_propagation.cpp
#include "taichi/ir/visitors.h"
#include "taichi/ir/statements.h"
#include <unordered_set>
#include <functional>
TLANG_NAMESPACE_BEGIN
namespace {
// A statement is considered constexpr in this pass, iff both its value and the
// control flow reaching it are const... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/Taichi", "path": "taichi/analysis/constexpr_propagation.cpp", "license": "mit", "size": 2773} |
### File: taichi/analysis/count_statements.cpp
#include "taichi/ir/ir.h"
#include "taichi/ir/analysis.h"
#include "taichi/ir/visitors.h"
TLANG_NAMESPACE_BEGIN
// Count all statements (including containers)
class StmtCounter : public BasicStmtVisitor {
private:
StmtCounter() {
counter = 0;
allow_undefined_v... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/Taichi", "path": "taichi/analysis/count_statements.cpp", "license": "mit", "size": 840} |
### File: taichi/analysis/data_source_analysis.cpp
#include "taichi/ir/ir.h"
#include "taichi/ir/analysis.h"
#include "taichi/ir/statements.h"
TLANG_NAMESPACE_BEGIN
namespace irpass::analysis {
std::vector<Stmt *> get_load_pointers(Stmt *load_stmt) {
// If load_stmt loads some variables or a stack, return the poin... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/Taichi", "path": "taichi/analysis/data_source_analysis.cpp", "license": "mit", "size": 3229} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.