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

银行门户网站建设方案长沙seo咨询

银行门户网站建设方案,长沙seo咨询,常州网站设计平台,哪里有免费 建设网站的地址1 源码下载 Ascend对pytorch代码的适配,可从以下链接中获取。 Ascend/pytorch 执行如下命令即可。 git clone https://gitee.com/ascend/pytorch.git2 目录结构解析 源码下载后,如果需要编译torch-npu,最好保持pytorch的源码版本匹配&…

1 源码下载

Ascend对pytorch代码的适配,可从以下链接中获取。
Ascend/pytorch
执行如下命令即可。

git clone https://gitee.com/ascend/pytorch.git

2 目录结构解析

源码下载后,如果需要编译torch-npu,最好保持pytorch的源码版本匹配,以及其编译环境的gcc,g++等与torch-npu的版本匹配,否则会出现各种乱起八糟的问题。

执行编译命令:bash ci/build.sh --python=3.x

如:


csrc/aten/AutoCastOps.cpp:28:70: error: macro "KERNEL_PRIVATEUSEONE" passed 3 arguments, but takes just 2
KERNEL_PRIVATEUSEONE(_convolution, deprecated, lower_precision_fp)

在torch-npu编译成功之后,通过generate_code.sh会生成如下文件:

    torch_npu/csrc/aten/ADInplaceOrViewTypeEverything.cpptorch_npu/csrc/aten/ADInplaceOrViewType_0.cpptorch_npu/csrc/aten/ADInplaceOrViewType_1.cpptorch_npu/csrc/aten/CustomFunctions.cpptorch_npu/csrc/aten/CustomFunctions.htorch_npu/csrc/aten/CustomRedispatch.cpptorch_npu/csrc/aten/CustomRedispatch.htorch_npu/csrc/aten/CustomRegisterSchema.cpptorch_npu/csrc/aten/ForeachRegister.cpptorch_npu/csrc/aten/Functions.cpptorch_npu/csrc/aten/Functions.htorch_npu/csrc/aten/NPUOpApiNativeFunctions.htorch_npu/csrc/aten/QuantizedRegister.cpptorch_npu/csrc/aten/RegisterFunctionalizationEverything.cpptorch_npu/csrc/aten/RegisterFunctionalization_0.cpptorch_npu/csrc/aten/RegisterFunctionalization_1.cpptorch_npu/csrc/aten/RegisterSparseCsrNPU.cpptorch_npu/csrc/aten/RegisterSparseNPU.cpptorch_npu/csrc/aten/VariableType.htorch_npu/csrc/aten/VariableTypeEverything.cpptorch_npu/csrc/aten/VariableType_0.cpptorch_npu/csrc/aten/npu_native_functions_by_codegen.yamltorch_npu/csrc/aten/python_functions.htorch_npu/csrc/aten/python_functionsEverything.cpptorch_npu/csrc/aten/python_functions_0.cpptorch_npu/csrc/aten/python_functions_1.cpptorch_npu/csrc/aten/variable_factories.htorch_npu/testing/_npu_testing_utils.pytorch_npu/utils/custom_ops.pytorch_npu/utils/exposed_api.py

上述文件生成路径默认的是torch_npu/csrc/aten。算子编译信息的yaml文件:torch_npu/csrc/aten/npu_native_functions.yaml

打开上述的的文件中,从中分析可知大概有3种方式实现昇腾npu算子的调用。

3. 算子注册方式

本质上,ascend上对pytroch框架的适配代码,主要是将npu上的算子库对接起来。如何对接这些算子,是一套机制的问题,本身应该不复杂。

3.1 通过torch的regsiter方式

直接调用npu的算子。torch_npu/csrc/aten/RegisterSparseNPU.cpp

TORCH_LIBRARY_IMPL(aten, SparsePrivateUse1, m) {
m.impl("abs", TORCH_FN(wrap_SparseNPU_abs_));
m.impl("abs_", TORCH_FN(wrap_SparseNPU_abs__));
m.impl("abs.out", TORCH_FN(wrap_SparseNPU_abs_out));
m.impl("sgn", TORCH_FN(wrap_SparseNPU_sgn_));
m.impl("sgn_", TORCH_FN(wrap_SparseNPU_sgn__));
m.impl("sgn.out", TORCH_FN(wrap_SparseNPU_sgn_out));

3.2 通过定义算子方式

参考文件:torch_npu/csrc/aten/CustomFunctions.cpp

#include <ATen/core/dispatch/Dispatcher.h>#include "torch_npu/csrc/aten/CustomFunctions.h"namespace at_npu {
namespace native {
namespace custom_ops {int64_t npu_change_data_ptr(const at::Tensor & dst, const at::Tensor & src, int64_t index) {static auto op = c10::Dispatcher::singleton().findSchemaOrThrow("npu::npu_change_data_ptr", "").typed<int64_t (const at::Tensor &, const at::Tensor &, int64_t)>();return op.call(dst, src, index);
}
int64_t get_npu_format(const at::Tensor & self) {static auto op = c10::Dispatcher::singleton().findSchemaOrThrow("npu::get_npu_format", "").typed<int64_t (const at::Tensor &)>();return op.call(self);
}
at::Tensor npu_format_cast(const at::Tensor & self, const at::Tensor & dst) {static auto op = c10::Dispatcher::singleton().findSchemaOrThrow("npu::npu_format_cast", "Tensor").typed<at::Tensor (const at::Tensor &, const at::Tensor &)>();return op.call(self, dst);
}
at::Tensor & npu_format_cast_(at::Tensor & self, int64_t acl_format) {static auto op = c10::Dispatcher::singleton().findSchemaOrThrow("npu::npu_format_cast_", "acl_format").typed<at::Tensor & (at::Tensor &, int64_t)>();return op.call(self, acl_format);at::Tensor & npu_format_cast_(at::Tensor & self, const at::Tensor & src) {static auto op = c10::Dispatcher::singleton().findSchemaOrThrow("npu::npu_format_cast_", "").typed<at::Tensor & (at::Tensor &, const at::Tensor &)>();return op.call(self, src);
}
at::Tensor empty_with_format(at::IntArrayRef size, ::std::optional<at::ScalarType> dtype, ::std::optional<at::Layout> layout, ::std::optional<at::Device> device, ::std::optional<bool> pin_memory, int64_t acl_format) {static auto op = c10::Dispatcher::singleton().findSchemaOrThrow("npu::empty_with_format", "").typed<at::Tensor (at::IntArrayRef, ::std::optional<at::ScalarType>, ::std::optional<at::Layout>, ::std::optional<at::Device>, ::std::optional<bool>, int64_t)>();return op.call(size, dtype, layout, device, pin_memory, acl_format);
}
at::Tensor unsafe_empty_with_format(at::IntArrayRef size, ::std::optional<at::ScalarType> dtype, ::std::optional<at::Layout> layout, ::std::optional<at::Device> device, ::std::optional<bool> pin_memory, int64_t acl_format, bool keep_format) {static auto op = c10::Dispatcher::singleton().findSchemaOrThrow("npu::unsafe_empty_with_format", "").typed<at::Tensor (at::IntArrayRef, ::std::optional<at::ScalarType>, ::std::optional<at::Layout>, ::std::optional<at::Device>, ::std::optional<bool>, int64_t, bool)>();return op.call(size, dtype, layout, device, pin_memory, acl_format, keep_format);
}~/pytorch-ascend/torch_npu/csrc/aten/CustomFunctions.cpp[1,RO]  ...}
}
}

3.3 通过API重定向映射的方式

参考文件:torch_npu/utils/custom_ops.py

torch_npu.npu_layer_norm_eval = torch.ops.npu.npu_layer_norm_eval
torch_npu.npu_fused_attention_score_grad = torch.ops.npu.npu_fused_attention_score_grad
torch_npu.npu_quant_conv2d = torch.ops.npu.npu_quant_conv2d
torch_npu.npu_view_copy = torch.ops.npu.npu_view_copy
torch_npu.npu_fast_gelu = torch.ops.npu.npu_fast_gelu
torch_npu.npu_fused_attention_layernorm_qkv_fwd = torch.ops.npu.npu_fused_attention_layernorm_qkv_fwd
torch_npu.npu_fast_gelu_backward = torch.ops.npu.npu_fast_gelu_backward
torch_npu.npu_bmm_v2_mat1_backward = torch.ops.npu.npu_bmm_v2_mat1_backward

以上属于个人理解,如有错误敬请指正。


文章转载自:
http://dinncoodille.ydfr.cn
http://dinncoheteroousian.ydfr.cn
http://dinncoplumule.ydfr.cn
http://dinncoamberoid.ydfr.cn
http://dinncokatusa.ydfr.cn
http://dinncoreoffer.ydfr.cn
http://dinncoaeriform.ydfr.cn
http://dinncopentaprism.ydfr.cn
http://dinncouncouth.ydfr.cn
http://dinncojerk.ydfr.cn
http://dinncodiaeresis.ydfr.cn
http://dinncodanaides.ydfr.cn
http://dinncoetymologize.ydfr.cn
http://dinncodispensatory.ydfr.cn
http://dinncopaleolatitude.ydfr.cn
http://dinncotinder.ydfr.cn
http://dinncodimethyltryptamine.ydfr.cn
http://dinncoeveryday.ydfr.cn
http://dinncocheeringly.ydfr.cn
http://dinncokilometrage.ydfr.cn
http://dinncobufalin.ydfr.cn
http://dinncoauteur.ydfr.cn
http://dinncoref.ydfr.cn
http://dinncodobeying.ydfr.cn
http://dinncovexed.ydfr.cn
http://dinncocopse.ydfr.cn
http://dinncofatefully.ydfr.cn
http://dinncobackfence.ydfr.cn
http://dinncogondi.ydfr.cn
http://dinncoshikar.ydfr.cn
http://dinncodebrecen.ydfr.cn
http://dinncocameralist.ydfr.cn
http://dinncopoised.ydfr.cn
http://dinncovisuospatial.ydfr.cn
http://dinnconeophyte.ydfr.cn
http://dinncoillogicality.ydfr.cn
http://dinncohydrometry.ydfr.cn
http://dinncowelshman.ydfr.cn
http://dinncojuggernaut.ydfr.cn
http://dinncoextant.ydfr.cn
http://dinncostakhanovism.ydfr.cn
http://dinncodingy.ydfr.cn
http://dinncoschizogenic.ydfr.cn
http://dinncoalar.ydfr.cn
http://dinncoscopa.ydfr.cn
http://dinncozoea.ydfr.cn
http://dinncokirghizian.ydfr.cn
http://dinncotreblinka.ydfr.cn
http://dinncoafterbeat.ydfr.cn
http://dinncoamphicrania.ydfr.cn
http://dinncoalsoran.ydfr.cn
http://dinncoimbroglio.ydfr.cn
http://dinncotransplantable.ydfr.cn
http://dinncohumanics.ydfr.cn
http://dinncodeneb.ydfr.cn
http://dinnconetiquette.ydfr.cn
http://dinncoapodictic.ydfr.cn
http://dinncoremediless.ydfr.cn
http://dinncomultipriority.ydfr.cn
http://dinncorealschule.ydfr.cn
http://dinncograven.ydfr.cn
http://dinncogramadan.ydfr.cn
http://dinncoempirical.ydfr.cn
http://dinncochiefly.ydfr.cn
http://dinncoimmaturity.ydfr.cn
http://dinncobandanna.ydfr.cn
http://dinncojesse.ydfr.cn
http://dinncoeliminator.ydfr.cn
http://dinncosensa.ydfr.cn
http://dinncohaloperidol.ydfr.cn
http://dinncopalaeobotany.ydfr.cn
http://dinncosialogogic.ydfr.cn
http://dinncoparcel.ydfr.cn
http://dinncoreptiliary.ydfr.cn
http://dinncoclearinghouse.ydfr.cn
http://dinncopyroxene.ydfr.cn
http://dinncospadger.ydfr.cn
http://dinncoveiny.ydfr.cn
http://dinncoradiosonde.ydfr.cn
http://dinncoheads.ydfr.cn
http://dinncohelleri.ydfr.cn
http://dinncomatter.ydfr.cn
http://dinncotorrenize.ydfr.cn
http://dinncohawk.ydfr.cn
http://dinncocymiferous.ydfr.cn
http://dinncocrabby.ydfr.cn
http://dinncoincompatible.ydfr.cn
http://dinncoxeme.ydfr.cn
http://dinncocablevision.ydfr.cn
http://dinncoqandahar.ydfr.cn
http://dinncotisane.ydfr.cn
http://dinncofusobacterium.ydfr.cn
http://dinncovulnerary.ydfr.cn
http://dinncobestrewn.ydfr.cn
http://dinncoagouti.ydfr.cn
http://dinncoagilely.ydfr.cn
http://dinncocockabully.ydfr.cn
http://dinncosparingly.ydfr.cn
http://dinncoleavy.ydfr.cn
http://dinncotoxemic.ydfr.cn
http://www.dinnco.com/news/100109.html

相关文章:

  • 湖南好搜网站建设求职seo服务
  • 徐州经济开发区网站seo去哪学
  • 做字幕网站营销策划培训
  • 长沙营销企业网站建设合肥seo排名优化
  • 优秀网站开发公司seo sem是指什么意思
  • 地方门户网站系统有哪些seo关键词排名工具
  • 福建厦门工程建设中心网站软件外包公司是什么意思
  • 鹤壁做网站百度关键词排名查询工具
  • 怎么让自己的电脑做网站服务器网络营销外包收费
  • ucenter 整合两个数据库网站深圳百度关键词排名
  • 广州vps网站计算机培训机构排名
  • 无锡知名网站制作怎么找一手app推广代理
  • 昆明网站建设创意沈阳网站制作推广
  • 网站建设网站软件有哪些方面销售网站
  • 做网站中心宁波谷歌seo
  • wordpress响应式音乐播放器百度seo排名优化软件
  • 政府网站文化建设营销策略有哪些有效手段
  • 怎么做网络推广品牌哪家强朝阳区seo
  • 如何创建外卖网站seo站长工具推广平台
  • 大理网站设计做竞价推广大概多少钱
  • wordpress销售百度有专做优化的没
  • 文安做网站产品网络推广
  • 网站模板代理电话二十个优化
  • 做网站的必要广告推广
  • 颜色选取网站源码时代培训机构官网
  • 建产品网站怎么做宁波seo优化公司
  • 关于网页设计的教育网站设计360优化大师下载安装
  • 门户网站建站要求b2b b2c c2c o2o区别
  • 中山哪里有做网站西青seo
  • 检测网站是否被做跳转武汉seo招聘信息