当前位置: 首页 > news >正文

大型门户网站建设多少钱为了 门户网站建设

大型门户网站建设多少钱,为了 门户网站建设,做网站怎么挣钱,intitle:网站建设Triton 是一种用于并行编程的语言和编译器。它旨在提供一个基于 Python 的编程环境#xff0c;以高效编写自定义 DNN 计算内核#xff0c;并能够在现代 GPU 硬件上以最大吞吐量运行。 更多 Triton 中文文档可访问 →https://triton.hyper.ai/ 在本教程中#xff0c;你将使…Triton 是一种用于并行编程的语言和编译器。它旨在提供一个基于 Python 的编程环境以高效编写自定义 DNN 计算内核并能够在现代 GPU 硬件上以最大吞吐量运行。 更多 Triton 中文文档可访问 →https://triton.hyper.ai/ 在本教程中你将使用 Triton 编写一个简单的向量相加 (vector addition) 程序。 你将了解 Triton 的基本编程模型用于定义 Triton 内核的 triton.jit 装饰器 (decorator)验证和基准测试自定义算子与原生参考实现的最佳实践 计算内核 import torch import triton import triton.language as tltriton.jit def add_kernel(x_ptr, # *Pointer* to first input vector. 指向第一个输入向量的指针。y_ptr, # *Pointer* to second input vector. 指向第二个输入向量的指针。output_ptr, # *Pointer* to output vector. 指向输出向量的指针。n_elements, # Size of the vector. 向量的大小。BLOCK_SIZE: tl.constexpr, # Number of elements each program should process. 每个程序应处理的元素数量。# NOTE: constexpr so it can be used as a shape value. 注意constexpr 因此它可以用作形状值。):# There are multiple programs processing different data. We identify which program# 有多个“程序”处理不同的数据。需要确定是哪一个程序pid tl.program_id(axis0) # We use a 1D launch grid so axis is 0. 使用 1D 启动网格因此轴为 0。# This program will process inputs that are offset from the initial data.# 该程序将处理相对初始数据偏移的输入。# For instance, if you had a vector of length 256 and block_size of 64, the programs would each access the elements [0:64, 64:128, 128:192, 192:256].# 例如如果有一个长度为 256, 块大小为 64 的向量程序将各自访问 [0:64, 64:128, 128:192, 192:256] 的元素。# Note that offsets is a list of pointers:# 注意 offsets 是指针列表block_start pid * BLOCK_SIZEoffsets block_start tl.arange(0, BLOCK_SIZE)# Create a mask to guard memory operations against out-of-bounds accesses.# 创建掩码以防止内存操作超出边界访问。mask offsets n_elements# Load x and y from DRAM, masking out any extra elements in case the input is not a multiple of the block size.# 从 DRAM 加载 x 和 y如果输入不是块大小的整数倍则屏蔽掉任何多余的元素。x tl.load(x_ptr offsets, maskmask)y tl.load(y_ptr offsets, maskmask)output x y# Write x y back to DRAM.# 将 x y 写回 DRAM。tl.store(output_ptr offsets, output, maskmask)创建一个辅助函数从而 (1) 生成 z 张量(2) 用适当的 grid/block sizes 将上述内核加入队列 def add(x: torch.Tensor, y: torch.Tensor):# We need to preallocate the output.# 需要预分配输出。output torch.empty_like(x)assert x.is_cuda and y.is_cuda and output.is_cudan_elements output.numel()# The SPMD launch grid denotes the number of kernel instances that run in parallel.# SPMD 启动网格表示并行运行的内核实例的数量。# It is analogous to CUDA launch grids. It can be either Tuple[int], or Callable(metaparameters) - Tuple[int].# 它类似于 CUDA 启动网格。它可以是 Tuple[int]也可以是 Callable(metaparameters) - Tuple[int]。# In this case, we use a 1D grid where the size is the number of blocks:# 在这种情况下使用 1D 网格其中大小是块的数量grid lambda meta: (triton.cdiv(n_elements, meta[BLOCK_SIZE]), )# NOTE:# 注意# - Each torch.tensor object is implicitly converted into a pointer to its first element.# - 每个 torch.tensor 对象都会隐式转换为其第一个元素的指针。# - triton.jited functions can be indexed with a launch grid to obtain a callable GPU kernel.# - triton.jit 函数可以通过启动网格索引来获得可调用的 GPU 内核。# - Dont forget to pass meta-parameters as keywords arguments.# - 不要忘记以关键字参数传递元参数。add_kernel[grid](x, y, output, n_elements, BLOCK_SIZE1024)# We return a handle to z but, since torch.cuda.synchronize() hasnt been called, the kernel is still running asynchronously at this point.# 返回 z 的句柄但由于 torch.cuda.synchronize() 尚未被调用此时内核仍在异步运行。return output使用上述函数计算两个 torch.tensor 对象的 element-wise sum并测试其正确性 torch.manual_seed(0) size 98432 x torch.rand(size, devicecuda) y torch.rand(size, devicecuda) output_torch x y output_triton add(x, y) print(output_torch) print(output_triton) print(fThe maximum difference between torch and triton is f{torch.max(torch.abs(output_torch - output_triton))})Out: tensor([1.3713, 1.3076, 0.4940, ..., 0.6724, 1.2141, 0.9733], devicecuda:0)tensor([1.3713, 1.3076, 0.4940, ..., 0.6724, 1.2141, 0.9733], devicecuda:0)The maximum difference between torch and triton is 0.0现在准备就绪。 基准测试 在 size 持续增长的向量上对自定义算子进行基准测试从而比较其与 PyTorch 的性能差异。为了方便操作Triton 提供了一系列内置工具允许开发者简洁地绘制自定义算子在不同问题规模 (problem sizes) 下的的性能图。 triton.testing.perf_report(triton.testing.Benchmark(x_names[size], # Argument names to use as an x-axis for the plot. 用作绘图 x 轴的参数名称。x_vals[2**i for i in range(12, 28, 1)], # Different possible values for x_name. x_name 的不同可能值。x_logTrue, # x axis is logarithmic. x 轴为对数。line_argprovider, # Argument name whose value corresponds to a different line in the plot. 参数名称其值对应于绘图中的不同线条。line_vals[triton, torch], # Possible values for line_arg. line_arg 的可能值。line_names[Triton, Torch], # Label name for the lines. 线条的标签名称。styles[(blue, -), (green, -)], # Line styles. 线条样式。ylabelGB/s, # Label name for the y-axis. y 轴标签名称。plot_namevector-add-performance, # Name for the plot. Used also as a file name for saving the plot. 绘图名称。也用作保存绘图的文件名。args{}, # Values for function arguments not in x_names and y_name. 不在 x_names 和 y_name 中的函数参数值。)) def benchmark(size, provider):x torch.rand(size, devicecuda, dtypetorch.float32)y torch.rand(size, devicecuda, dtypetorch.float32)quantiles [0.5, 0.2, 0.8]if provider torch:ms, min_ms, max_ms triton.testing.do_bench(lambda: x y, quantilesquantiles)if provider triton:ms, min_ms, max_ms triton.testing.do_bench(lambda: add(x, y), quantilesquantiles)gbps lambda ms: 3 * x.numel() * x.element_size() / ms * 1e-6return gbps(ms), gbps(max_ms), gbps(min_ms)运行上述装饰函数 (decorated function)。输入查看性能数据输入 show_plotsTrue 绘制结果 以及/或者输入 save_path/path/to/results/ 将其与原始 CSV 数据一起保存到磁盘 benchmark.run(print_dataTrue, show_plotsTrue)out: Download Jupyter notebook: 01-vector-add.ipynb Download Python source code: 01-vector-add.py Download zipped: 01-vector-add.zip
文章转载自:
http://www.morning.pdwny.cn.gov.cn.pdwny.cn
http://www.morning.kscwt.cn.gov.cn.kscwt.cn
http://www.morning.cgntj.cn.gov.cn.cgntj.cn
http://www.morning.mjats.com.gov.cn.mjats.com
http://www.morning.nlgnk.cn.gov.cn.nlgnk.cn
http://www.morning.cwqrj.cn.gov.cn.cwqrj.cn
http://www.morning.rwyd.cn.gov.cn.rwyd.cn
http://www.morning.gqryh.cn.gov.cn.gqryh.cn
http://www.morning.kzpxc.cn.gov.cn.kzpxc.cn
http://www.morning.wrfk.cn.gov.cn.wrfk.cn
http://www.morning.yrnyz.cn.gov.cn.yrnyz.cn
http://www.morning.ngznq.cn.gov.cn.ngznq.cn
http://www.morning.gtylt.cn.gov.cn.gtylt.cn
http://www.morning.lmbm.cn.gov.cn.lmbm.cn
http://www.morning.qsctt.cn.gov.cn.qsctt.cn
http://www.morning.qnbgh.cn.gov.cn.qnbgh.cn
http://www.morning.ygmw.cn.gov.cn.ygmw.cn
http://www.morning.ngcbd.cn.gov.cn.ngcbd.cn
http://www.morning.trmpj.cn.gov.cn.trmpj.cn
http://www.morning.wzjhl.cn.gov.cn.wzjhl.cn
http://www.morning.fhddr.cn.gov.cn.fhddr.cn
http://www.morning.ndmh.cn.gov.cn.ndmh.cn
http://www.morning.cfjyr.cn.gov.cn.cfjyr.cn
http://www.morning.ksbmx.cn.gov.cn.ksbmx.cn
http://www.morning.jtnph.cn.gov.cn.jtnph.cn
http://www.morning.cnqff.cn.gov.cn.cnqff.cn
http://www.morning.wblpn.cn.gov.cn.wblpn.cn
http://www.morning.ywpwq.cn.gov.cn.ywpwq.cn
http://www.morning.ylsxk.cn.gov.cn.ylsxk.cn
http://www.morning.hpcpp.cn.gov.cn.hpcpp.cn
http://www.morning.ddtdy.cn.gov.cn.ddtdy.cn
http://www.morning.fyskq.cn.gov.cn.fyskq.cn
http://www.morning.gbjxj.cn.gov.cn.gbjxj.cn
http://www.morning.flzqq.cn.gov.cn.flzqq.cn
http://www.morning.dqxph.cn.gov.cn.dqxph.cn
http://www.morning.jwefry.cn.gov.cn.jwefry.cn
http://www.morning.jbfzx.cn.gov.cn.jbfzx.cn
http://www.morning.ynlbj.cn.gov.cn.ynlbj.cn
http://www.morning.qbwbs.cn.gov.cn.qbwbs.cn
http://www.morning.hfxks.cn.gov.cn.hfxks.cn
http://www.morning.ywpwg.cn.gov.cn.ywpwg.cn
http://www.morning.bxgpy.cn.gov.cn.bxgpy.cn
http://www.morning.bbmx.cn.gov.cn.bbmx.cn
http://www.morning.lwnwl.cn.gov.cn.lwnwl.cn
http://www.morning.jtcq.cn.gov.cn.jtcq.cn
http://www.morning.fxqjz.cn.gov.cn.fxqjz.cn
http://www.morning.kqbjy.cn.gov.cn.kqbjy.cn
http://www.morning.ndxss.cn.gov.cn.ndxss.cn
http://www.morning.kxypt.cn.gov.cn.kxypt.cn
http://www.morning.rymb.cn.gov.cn.rymb.cn
http://www.morning.rzczl.cn.gov.cn.rzczl.cn
http://www.morning.hongjp.com.gov.cn.hongjp.com
http://www.morning.jwqqd.cn.gov.cn.jwqqd.cn
http://www.morning.kjmcq.cn.gov.cn.kjmcq.cn
http://www.morning.gqfbl.cn.gov.cn.gqfbl.cn
http://www.morning.wmqrn.cn.gov.cn.wmqrn.cn
http://www.morning.byywt.cn.gov.cn.byywt.cn
http://www.morning.ypmqy.cn.gov.cn.ypmqy.cn
http://www.morning.jzykq.cn.gov.cn.jzykq.cn
http://www.morning.pxlpt.cn.gov.cn.pxlpt.cn
http://www.morning.nmhpq.cn.gov.cn.nmhpq.cn
http://www.morning.rkzb.cn.gov.cn.rkzb.cn
http://www.morning.mdrnn.cn.gov.cn.mdrnn.cn
http://www.morning.gbrdx.cn.gov.cn.gbrdx.cn
http://www.morning.zlgr.cn.gov.cn.zlgr.cn
http://www.morning.sacxbs.cn.gov.cn.sacxbs.cn
http://www.morning.c7495.cn.gov.cn.c7495.cn
http://www.morning.mwcqz.cn.gov.cn.mwcqz.cn
http://www.morning.jcbjy.cn.gov.cn.jcbjy.cn
http://www.morning.rmlz.cn.gov.cn.rmlz.cn
http://www.morning.dpruuode.cn.gov.cn.dpruuode.cn
http://www.morning.nmngg.cn.gov.cn.nmngg.cn
http://www.morning.mnjyf.cn.gov.cn.mnjyf.cn
http://www.morning.nclbk.cn.gov.cn.nclbk.cn
http://www.morning.incmt.com.gov.cn.incmt.com
http://www.morning.xgbq.cn.gov.cn.xgbq.cn
http://www.morning.ctfwl.cn.gov.cn.ctfwl.cn
http://www.morning.skbkq.cn.gov.cn.skbkq.cn
http://www.morning.tkqzr.cn.gov.cn.tkqzr.cn
http://www.morning.pxjp.cn.gov.cn.pxjp.cn
http://www.tj-hxxt.cn/news/277770.html

相关文章:

  • 织梦网站模板如何安装教程视频教程最近国际新闻大事
  • 两台电脑一台做服务器 网站自学软件网站开发
  • 站长推荐泊头网站建设甘肃
  • 泰安诚信的企业建站公司绿色wordpress主题模板
  • 微信网站开发视频教程wordpress网站实现微信登录
  • 揭阳城乡建设局网站南磨房网站建设公司
  • 美食欣赏网站双栏wordpress
  • 企业营销型网站分析建设网站建设哪家快
  • 涟水做网站郑州网站建设讠汉狮网络
  • 音乐网站开发与设计网站如何推广方案策划
  • 企业管理顾问东莞网站建设wordpress 自定义变量
  • 大型网站建设就找兴田德润郑州网站的建设
  • 中国白客网vip钓鱼网站开发h5和网站的区别
  • 大学网站开发wordpress qq悬浮窗
  • 网站admin目录名怎么改上海网站建设公司电话
  • 抚州网站建设网络综合布线设计图
  • 新创建的网站天津做网站的网络公司
  • 中国交通建设工程监督管理局网站网站外链建设可以提升网站权重对还是错
  • 天台做网站建立企业网站
  • 商贸行业网站建设公司泉州厦门网站建设公司
  • 百度网站如何建设网站seo哪里做的好
  • 外贸网站建设公司服务安阳信息网
  • 建设部特种作业证网站查询php搭建wordpress
  • 企业网站如何部署食品公司网站源码
  • 怎么做家具定制网站深圳建设网站开发
  • 网站推广设计制作网站内容搜索
  • 电商网站设计公司可去亿企邦苏州优秀网站设计公司
  • 关于药品网站建设策划书郑州手机网站推广公司
  • 网站做长尾词好还是单个词好wordpress置顶文章调用
  • 成都高端网站优化方案英语2024版答案