python库taichi太极人工智能tensoflow图形处理-泓源视野

python库taichi太极人工智能tensoflow图形处理

Hello, world!
We introduce the Taichi programming language through a very basic fractal example.

Running the Taichi code below (python3 fractal.py or ti example fractal) will give you an animation of Julia set:

https://github.com/yuanming-hu/public_files/raw/master/graphics/taichi/fractal.gif
# fractal.py

import taichi as ti

ti.init(arch=ti.gpu)

n = 320
pixels = ti.field(dtype=float, shape=(n * 2, n))

@ti.func
def complex_sqr(z):
return ti.Vector([z[0]**2 - z[1]**2, z[1] * z[0] * 2])

@ti.kernel
def paint(t: float):
for i, j in pixels: # Parallized over all pixels
c = ti.Vector([-0.8, ti.cos(t) * 0.2])
z = ti.Vector([i / n - 1, j / n - 0.5]) * 2
iterations = 0
while z.norm() < 20 and iterations < 50:
z = complex_sqr(z) + c
iterations += 1
pixels[i, j] = 1 - iterations * 0.02

gui = ti.GUI("Julia Set", res=(n * 2, n))

for i in range(1000000):
paint(i * 0.03)
gui.set_image(pixels)
gui.show()

 

Taichi(太极)0.7.1 已经发布,这是专为高性能计算机图形学设计的编程语言。

python库taichi太极人工智能tensoflow图形处理插图

此版本具体更新内容如下:

Highlights

  • Bug 修复
    • 修复一些缺少的 operator overrides,例如 rlshift。
  • CUDA backend
    • 支持  NVIDIA RTX 3000 series GPUs
  • Language and syntax
    • 添加 ti.loop_unique(val) 以改善  atomics demotion
  • Type system
    • 实现 is_primitive 并重构 primitive type equality check
本文由 泓源视野 作者:admin 发表,其版权均为 泓源视野 所有,文章内容系作者个人观点,不代表 泓源视野 对观点赞同或支持。如需转载,请注明文章来源。
14

发表评论

Protected with IP Blacklist CloudIP Blacklist Cloud
您是第8236162 位访客, 您的IP是:[3.135.183.89]