[CC]Dynamic GCD

本文介绍了一种高效算法,用于解决带权树中路径上的最大公约数(GCD)查询及更新问题。通过差分序列和树状数组等数据结构优化了查询效率,最终实现O(nlog³n)的时间复杂度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题意简述

一棵n个点的带权树。F询问一条路径上所有点的gcd,或C将一条路径上所有点权+d

数据范围

1n50000
1ai,d1000

思路

如果维护gcd很难维护。
gcd(x,y)=gcd(x,xy)
我们可以维护差分序列,将区间加转化为单点操作。
每次询问,起始端是原数,后面是差分数列。
再用树状数组维护一下原数。
复杂度O(nlog3n)

代码

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
using namespace std;
#define MAXN 50010
struct edge{
    int s,t,next;
}e[MAXN<<1];
int head[MAXN],cnt;
void addedge(int s,int t)
{
    e[cnt].s=s;e[cnt].t=t;e[cnt].next=head[s];head[s]=cnt++;
    e[cnt].s=t;e[cnt].t=s;e[cnt].next=head[t];head[t]=cnt++;
}
int n,ord,u,v,w,q;
char opt;
int deep[MAXN],fa[MAXN],size[MAXN],son[MAXN],top[MAXN],dfn[MAXN],seq[MAXN],a[MAXN];
void dfs1(int node,int lastfa,int de)
{
    deep[node]=de;
    fa[node]=lastfa;
    size[node]=1;
    son[node]=0;
    for (int i=head[node];i!=-1;i=e[i].next)
        if (e[i].t!=lastfa)
        {
            dfs1(e[i].t,node,de+1);
            size[node]+=size[e[i].t];
            if (size[e[i].t]>size[son[node]])
                son[node]=e[i].t;
        }
}
void dfs2(int node,int lastfa,int tp)
{
    top[node]=tp;
    dfn[node]=++ord;
    seq[ord]=a[node];
    if (son[node])
        dfs2(son[node],node,tp);
    for (int i=head[node];i!=-1;i=e[i].next)
        if (e[i].t!=lastfa&&e[i].t!=son[node])
            dfs2(e[i].t,node,e[i].t);
}
int gcd(int a,int b)
{
    if (a<0||b<0)
        return gcd(abs(a),abs(b));
    if (!b)
        return a;
    return gcd(b,a%b);
}
namespace Segtree
{
    struct Node{
        int val;
    }tree[MAXN<<2];
    int pushup(int node)
    {
        tree[node].val=gcd(tree[node<<1].val,tree[node<<1|1].val);
    }
    void build(int l,int r,int node)
    {
        if (l==r)
        {
            tree[node].val=seq[l];
            return;
        }
        int mid=(l+r)>>1;
        build(l,mid,node<<1);
        build(mid+1,r,node<<1|1);
        pushup(node);
    }
    void modify(int pos,int l,int r,int node,int w)
    {
        if (l==r)
        {
            tree[node].val+=w;
            return;
        }
        int mid=(l+r)>>1;
        if (pos<=mid)
            modify(pos,l,mid,node<<1,w);
        else
            modify(pos,mid+1,r,node<<1|1,w);
        pushup(node);
    }
    int query(int L,int R,int l,int r,int node)
    {
        if (L<=l&&r<=R)
            return tree[node].val;
        int mid=(l+r)>>1;
        int ret=0;
        if (L<=mid)
            ret=gcd(ret,query(L,R,l,mid,node<<1));
        if (R>mid)
            ret=gcd(ret,query(L,R,mid+1,r,node<<1|1));
        return ret;
    }
}
struct BIT{
    static const int size=50000;
    int d[50010];
    int lowbit(int x)
    {
        return x&(-x);
    }
    void modify(int l,int r,int val)
    {
        for (;l<=size;l+=lowbit(l))
            d[l]+=val;
        for (++r;r<=size;r+=lowbit(r))
            d[r]-=val;
    }
    int query(int pos)
    {
        int ret=0;
        for (;pos;pos-=lowbit(pos))
            ret+=d[pos];
        return ret;
    }
}T;
void solve_modify(int u,int v,int w)
{
    int tu=top[u],tv=top[v],ret=0;
    while (tu!=tv)
    {
        if (deep[tu]<deep[tv])
            swap(u,v),swap(tu,tv);
        T.modify(dfn[tu],dfn[u],w);
        Segtree::modify(dfn[tu],1,n,1,w);
        if (dfn[u]+1<=n)
            Segtree::modify(dfn[u]+1,1,n,1,-w); 
        u=fa[tu];
        tu=top[u];
    }
    if (deep[u]>deep[v])
        swap(u,v);
    T.modify(dfn[u],dfn[v],w);
    Segtree::modify(dfn[u],1,n,1,w);
    if (dfn[v]+1<=n)
        Segtree::modify(dfn[v]+1,1,n,1,-w);
}
int solve_query(int u,int v)
{
    int tu=top[u],tv=top[v],ret=0;
    while (tu!=tv)
    {
        if (deep[tu]<deep[tv])
            swap(u,v),swap(tu,tv);
        ret=gcd(ret,T.query(dfn[tu]));
        if (dfn[tu]+1<=dfn[u])
            ret=gcd(ret,Segtree::query(dfn[tu]+1,dfn[u],1,n,1));
        u=fa[tu];
        tu=top[u];
    }
    if (deep[u]>deep[v])
        swap(u,v);
    ret=gcd(ret,T.query(dfn[u]));
    if (dfn[u]+1<=dfn[v])
        ret=gcd(ret,Segtree::query(dfn[u]+1,dfn[v],1,n,1));
    return ret;
}
char read()
{
    char ch=getchar();
    while (ch!='F'&&ch!='C')
        ch=getchar();
    return ch;
}
int main()
{
    scanf("%d",&n);
    memset(head,0xff,sizeof(head));
    cnt=0;
    for (int i=1;i<n;i++)
    {
        scanf("%d%d",&u,&v);
        u++,v++;
        addedge(u,v);
    }
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    dfs1(1,1,1);
    dfs2(1,1,1);
    for (int i=1;i<=n;i++)
        T.modify(i,i,seq[i]);
    for (int i=n;i>=1;i--)
        seq[i]-=seq[i-1];
    Segtree::build(1,n,1);
    scanf("%d",&q);
    for (int i=1;i<=q;i++)
    {
        opt=read();
        if (opt=='F')
        {
            scanf("%d%d",&u,&v);
            u++,v++;
            printf("%d\n",solve_query(u,v));
        }
        else
        {
            scanf("%d%d%d",&u,&v,&w);
            u++,v++;
            solve_modify(u,v,w);
        }
    }
    return 0;
}
2025-03-20 20:08:04.900483: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2025-03-20 20:08:04.900788: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. Traceback (most recent call last): File "D:\Desktop\vegetables_tf2.3-master\vegetables_tf2.3-master\train_cnn.py", line 115, in <module> train(epochs=30) File "D:\Desktop\vegetables_tf2.3-master\vegetables_tf2.3-master\train_cnn.py", line 98, in train "D:/1/WeChat Files/wxid_c6n47k03okeu22/FileStorage/File/2024-05/vegetables_tf2.3-master/data/valid", 224, 224, 16) File "D:\Desktop\vegetables_tf2.3-master\vegetables_tf2.3-master\train_cnn.py", line 17, in data_load train_ds = tf.keras.preprocessing.image_dataset_from_directory( File "C:\Users\yi'yang\.conda\envs\tf2.6\lib\site-packages\tensorflow\python\util\lazy_loader.py", line 62, in __getattr__ module = self._load() File "C:\Users\yi'yang\.conda\envs\tf2.6\lib\site-packages\tensorflow\python\util\lazy_loader.py", line 45, in _load module = importlib.import_module(self.__name__) File "C:\Users\yi'yang\.conda\envs\tf2.6\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 100
03-21
C:\Users\yi'yang\.conda\envs\tf2.6\python.exe D:\Desktop\vegetables_tf2.3-master\vegetables_tf2.3-master\train_cnn.py 2025-03-20 19:22:17.118095: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2025-03-20 19:22:17.118233: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. Traceback (most recent call last): File "D:\Desktop\vegetables_tf2.3-master\vegetables_tf2.3-master\train_cnn.py", line 115, in <module> train(epochs=30) File "D:\Desktop\vegetables_tf2.3-master\vegetables_tf2.3-master\train_cnn.py", line 98, in train "D:/1/WeChat Files/wxid_c6n47k03okeu22/FileStorage/File/2024-05/vegetables_tf2.3-master/data/valid", 224, 224, 16) File "D:\Desktop\vegetables_tf2.3-master\vegetables_tf2.3-master\train_cnn.py", line 17, in data_load train_ds = tf.keras.preprocessing.image_dataset_from_directory( File "C:\Users\yi'yang\.conda\envs\tf2.6\lib\site-packages\tensorflow\python\util\lazy_loader.py", line 62, in __getattr__ module = self._load() File "C:\Users\yi'yang\.conda\envs\tf2.6\lib\site-packages\tensorflow\python\util\lazy_loader.py", line 45, in _load module = importlib.import_module(self.__name__) File "C:\Users\yi'yang\.conda\envs\tf2.6\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked File "
03-21
C:\Users\ggbond\AppData\Local\anaconda3\envs\ZHINENGYOUHUA\python.exe C:/Users/ggbond/Desktop/基于深度学习的中文语音识别系统(完整代码+报告+毕业设计)/deepspeechrecognition/test.py 2025-03-19 12:49:49.343439: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll Traceback (most recent call last): File "C:/Users/ggbond/Desktop/基于深度学习的中文语音识别系统(完整代码+报告+毕业设计)/deepspeechrecognition/test.py", line 6, in <module> from utils import decode_ctc, GetEditDistance File "C:\Users\ggbond\Desktop\基于深度学习的中文语音识别系统(完整代码+报告+毕业设计)\deepspeechrecognition\utils.py", line 4, in <module> import tensorflow as tf File "C:\Users\ggbond\AppData\Local\anaconda3\envs\ZHINENGYOUHUA\lib\site-packages\tensorflow\__init__.py", line 101, in <module> from tensorflow_core import * File "C:\Users\ggbond\AppData\Local\anaconda3\envs\ZHINENGYOUHUA\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module> from tensorflow.python.tools import module_util as _module_util File "C:\Users\ggbond\AppData\Local\anaconda3\envs\ZHINENGYOUHUA\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__ module = self._load() File "C:\Users\ggbond\AppData\Local\anaconda3\envs\ZHINENGYOUHUA\lib\site-packages\tensorflow\__init__.py", line 44, in _load module = _importlib.import_module(self.__name__) File "C:\Users\ggbond\AppData\Local\anaconda3\envs\ZHINENGYOUHUA\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "C:\Users\ggbond\AppData\Local\anaconda3\envs\ZHINENGYOUHUA\lib\site-packages\tensorflow_core\python\__init__.py", line 64, in <module> from tensorflow.core.framework.graph_pb2 import * File "C:\Users\ggbond\AppData\Local\anaconda3\envs\ZHINENGYOUHUA\lib\site-packages\tensorflow_core\core\framework\graph_pb2.py", line 7, in <module> from google.protobuf import descriptor as _descriptor ImportError: cannot import name 'descriptor'
03-20
华为云Ascend C算子开发 环境搭(MindSpore) [ma-user SigmoidCustom]$bash build.sh using ASCEND_HOME_PATH: /home/ma-user/Ascend/ascend-toolkit/latest Preset CMake variables: ASCEND_COMPUTE_UNIT:STRING="ascend310b;ascend910b" ASCEND_PYTHON_EXECUTABLE:STRING="python3" CMAKE_BUILD_TYPE:STRING="Release" CMAKE_CROSS_PLATFORM_COMPILER:PATH="/usr/bin/aarch64-linux-gnu-g++" CMAKE_INSTALL_PREFIX:PATH="/home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out" ENABLE_BINARY_PACKAGE:BOOL="True" ENABLE_CROSS_COMPILE:BOOL="False" ENABLE_SOURCE_PACKAGE:BOOL="True" ENABLE_TEST:BOOL="True" vendor_name:STRING="customize" -- The C compiler identification is GNU 7.3.0 CMake Warning (dev) at /home/ma-user/work/cmake-3.28.3-linux-aarch64/share/cmake-3.28/Modules/CMakeFindBinUtils.cmake:224 (find_program): Policy CMP0109 is not set: find_program() requires permission to execute but not to read. Run "cmake --help-policy CMP0109" for policy details. Use the cmake_policy command to set the policy and suppress this warning. The file /usr/bin/ld is executable but not readable. CMake is ignoring it for compatibility. Call Stack (most recent call first): /home/ma-user/work/cmake-3.28.3-linux-aarch64/share/cmake-3.28/Modules/CMakeDetermineCCompiler.cmake:196 (include) CMakeLists.txt:2 (project) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at /home/ma-user/work/cmake-3.28.3-linux-aarch64/share/cmake-3.28/Modules/CMakeFindBinUtils.cmake:224 (find_program): Policy CMP0109 is not set: find_program() requires permission to execute but not to read. Run "cmake --help-policy CMP0109" for policy details. Use the cmake_policy command to set the policy and suppress this warning. The file /bin/ld is executable but not readable. CMake is ignoring it for compatibility. Call Stack (most recent call first): /home/ma-user/work/cmake-3.28.3-linux-aarch64/share/cmake-3.28/Modules/CMakeDetermineCCompiler.cmake:196 (include) CMakeLists.txt:2 (project) This warning is for project developers. Use -Wno-dev to suppress it. -- The CXX compiler identification is GNU 7.3.0 CMake Warning (dev) at /home/ma-user/work/cmake-3.28.3-linux-aarch64/share/cmake-3.28/Modules/CMakeFindBinUtils.cmake:224 (find_program): Policy CMP0109 is not set: find_program() requires permission to execute but not to read. Run "cmake --help-policy CMP0109" for policy details. Use the cmake_policy command to set the policy and suppress this warning. The file /usr/bin/ld is executable but not readable. CMake is ignoring it for compatibility. Call Stack (most recent call first): /home/ma-user/work/cmake-3.28.3-linux-aarch64/share/cmake-3.28/Modules/CMakeDetermineCXXCompiler.cmake:202 (include) CMakeLists.txt:2 (project) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at /home/ma-user/work/cmake-3.28.3-linux-aarch64/share/cmake-3.28/Modules/CMakeFindBinUtils.cmake:224 (find_program): Policy CMP0109 is not set: find_program() requires permission to execute but not to read. Run "cmake --help-policy CMP0109" for policy details. Use the cmake_policy command to set the policy and suppress this warning. The file /bin/ld is executable but not readable. CMake is ignoring it for compatibility. Call Stack (most recent call first): /home/ma-user/work/cmake-3.28.3-linux-aarch64/share/cmake-3.28/Modules/CMakeDetermineCXXCompiler.cmake:202 (include) CMakeLists.txt:2 (project) This warning is for project developers. Use -Wno-dev to suppress it. -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Opbuild generating sources -- Opbuild generating sources - done -- Configuring done (3.3s) -- Generating done (0.0s) CMake Warning: Manually-specified variables were not used by the project: CMAKE_CROSS_PLATFORM_COMPILER -- Build files have been written to: /home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out [ 7%] Building CXX object op_host/CMakeFiles/cust_optiling.dir/sigmoid_custom.cpp.o [ 14%] Building CXX object framework/tf_plugin/CMakeFiles/cust_tf_parsers.dir/tensorflow_sigmoid_custom_plugin.cc.o [ 21%] Generating scripts/install.sh, scripts/upgrade.sh [ 28%] Building CXX object op_host/CMakeFiles/cust_opapi.dir/__/autogen/aclnn_sigmoid_custom.cpp.o [ 28%] Built target gen_version_info [ 57%] Building CXX object op_host/CMakeFiles/cust_op_proto.dir/__/autogen/op_proto.cc.o [ 57%] Generating tbe/op_info_cfg/ai_core/ascend310b/aic-ascend310b-ops-info.json [ 57%] Generating tbe/.impl_timestamp [ 64%] Building CXX object op_host/CMakeFiles/cust_op_proto.dir/sigmoid_custom.cpp.o [ 64%] Generating tbe/op_info_cfg/ai_core/ascend910b/aic-ascend910b-ops-info.json [ 71%] Generating tbe/op_info_cfg/ai_core/npu_supported_ops.json /home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out/autogen /home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out/op_kernel/tbe/op_info_cfg/ai_core [ 71%] Built target modify_vendor ==============check valid for ops info start============== ==============check valid for ops info end================ ==============check valid for ops info start============== ==============check valid for ops info end================ Compile op info cfg successfully. Compile op info cfg successfully. [ 71%] Built target ops_info_gen_ascend310b [ 71%] Built target ops_info_gen_ascend910b [INFO] Succed generated /home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out/op_kernel/tbe/op_info_cfg/ai_core/npu_supported_ops.json [ 71%] Built target ascendc_impl_gen [ 71%] Built target npu_supported_ops [ 78%] Linking CXX shared library libcust_opapi.so [ 78%] Built target cust_opapi [ 85%] Linking CXX shared library libcust_tf_parsers.so [ 85%] Built target cust_tf_parsers [ 92%] Linking CXX shared library libcust_opsproto_rt2.0.so [100%] Linking CXX shared library libcust_opmaster_rt2.0.so [100%] Built target cust_op_proto [100%] Built target cust_optiling [100%] Built target optiling_compat Run CPack packaging tool... CPack: Create package using External CPack: Install projects CPack: - Run preinstall target for: opp CPack: - Install project: opp [] CPack: Create package About to compress 596 KB of data... Adding files to archive named "custom_opp_euleros_aarch64.run"... ./help.info ./install.sh ./packages/vendors/customize/framework/tensorflow/libcust_tf_parsers.so ./packages/vendors/customize/framework/tensorflow/npu_supported_ops.json ./packages/vendors/customize/op_api/include/aclnn_sigmoid_custom.h ./packages/vendors/customize/op_api/lib/libcust_opapi.so ./packages/vendors/customize/op_impl/ai_core/tbe/config/ascend310b/aic-ascend310b-ops-info.json ./packages/vendors/customize/op_impl/ai_core/tbe/config/ascend910b/aic-ascend910b-ops-info.json ./packages/vendors/customize/op_impl/ai_core/tbe/customize_impl/dynamic/sigmoid_custom.cpp ./packages/vendors/customize/op_impl/ai_core/tbe/customize_impl/dynamic/sigmoid_custom.py ./packages/vendors/customize/op_impl/ai_core/tbe/kernel/ascend310b/sigmoid_custom/ ./packages/vendors/customize/op_impl/ai_core/tbe/kernel/ascend910b/sigmoid_custom/ ./packages/vendors/customize/op_impl/ai_core/tbe/kernel/config/ascend310b/ ./packages/vendors/customize/op_impl/ai_core/tbe/kernel/config/ascend910b/ ./packages/vendors/customize/op_impl/ai_core/tbe/op_tiling/lib/linux/aarch64/libcust_opmaster_rt2.0.so ./packages/vendors/customize/op_impl/ai_core/tbe/op_tiling/liboptiling.so ./packages/vendors/customize/op_proto/inc/op_proto.h ./packages/vendors/customize/op_proto/lib/linux/aarch64/libcust_opsproto_rt2.0.so ./packages/vendors/customize/version.info ./upgrade.sh CRC: 1499435367 SHA256: 132259459f6127571b863c6b1d537ab0b4bc03d419dcefd6159d37927d379782 Skipping md5sum at user request Self-extractable archive "custom_opp_euleros_aarch64.run" successfully created. Copy /home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out/_CPack_Packages/Linux/External/custom_opp_euleros_aarch64.run/custom_opp_euleros_aarch64.run to /home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out/ CPack: - package: /home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out/custom_opp_euleros_aarch64.run.json generated. CPack: - package: /home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out/custom_opp_euleros_aarch64.run generated. Verifying archive integrity... 100% SHA256 checksums are OK. All good. Uncompressing version:1.0 100% [ops_custom] [2025-06-23 23:33:13] [INFO] copy uninstall sh success [ops_custom] [2025-06-23 23:33:13] [INFO] upgrade framework tensorflow [ops_custom] [2025-06-23 23:33:13] [INFO] replace or merge old ops framework files .g..... [ops_custom] [2025-06-23 23:33:13] copy new ops framework files ...... [ops_custom] [2025-06-23 23:33:14] [INFO] upgrade op proto inc lib [ops_custom] [2025-06-23 23:33:14] [INFO] replace or merge old ops op_proto files .g..... [ops_custom] [2025-06-23 23:33:14] copy new ops op_proto files ...... [ops_custom] [2025-06-23 23:33:14] [INFO] upgrade op impl ai_core [ops_custom] [2025-06-23 23:33:14] [INFO] replace or merge old ops op_impl files .g..... [ops_custom] [2025-06-23 23:33:14] copy new ops op_impl files ...... [ops_custom] [2025-06-23 23:33:14] [INFO] upgrade op api include lib [ops_custom] [2025-06-23 23:33:14] [INFO] replace or merge old ops op_api files .g..... [ops_custom] [2025-06-23 23:33:14] copy new ops op_api files ...... [ops_custom] [2025-06-23 23:33:14] [INFO] upgrade version.info [ops_custom] [2025-06-23 23:33:14] copy new version.info files ...... [ops_custom] [2025-06-23 23:33:14] [INFO] no need to upgrade custom.proto files [ops_custom] [2025-06-23 23:33:14] [INFO] using requirements: when custom module install finished or before you run the custom module, execute the command [ export LD_LIBRARY_PATH=/home/ma-user/Ascend/ascend-toolkit/latest/opp/vendors/customize/op_api/lib/:${LD_LIBRARY_PATH} ] to set the environment path SUCCESS [100%] Built target ascendc_impl_gen [100%] Built target ascendc_bin_ascend910b_sigmoid_custom_copy [100%] Built target ascendc_bin_ascend310b_sigmoid_custom_copy [100%] Built target ascendc_bin_ascend910b [100%] Built target ascendc_bin_ascend310b [Ascend310B1] Generating SigmoidCustom_a3c9eb1f1b227778957282b95ed93786 ... [Ascend910B1] Generating SigmoidCustom_a3c9eb1f1b227778957282b95ed93786 ... [ERROR] TBE(123105,python3):2025-06-23-23:33:18.348.085 [../../../opc_tool/opc_common.py:218][_log_error] Traceback (most recent call last): File "/home/ma-user/Ascend/ascend-toolkit/8.0.RC1.alpha002/python/site-packages/opc_tool/op_compilation.py", line 417, in get_op_func_attr opm = importlib.import_module(op_module) File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module [ERROR] TBE(123105,python3):2025-06-23-23:33:18.348.235 [../../../opc_tool/opc_common.py:218][_log_error] File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out/op_kernel/binary/ascend910b/src/SigmoidCustom.py", line 14, in <module> from tbe.tikcpp.compile_op import CommonUtility, AscendCLogLevel ImportError: cannot import name 'CommonUtility' from 'tbe.tikcpp.compile_op' (/home/ma-user/Ascend/ascend-toolkit/8.0.RC1.alpha002/python/site-packages/tbe/tikcpp/compile_op.py) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/ma-user/Ascend/ascend-toolkit/8.0.RC1.alpha002/python/site-packages/opc_tool/op_compilation.py", line 559, in single_op_compilation self.__op_compile_by_json_info(json_dict) [ERROR] TBE(123105,python3):2025-06-23-23:33:18.348.409 [../../../opc_tool/op_compilation.py:562][single_op_compilation] Compile failed, reason is: import src.SigmoidCustom error, reason:cannot import name 'CommonUtility' from 'tbe.tikcpp.compile_op' (/home/ma-user/Ascend/ascend-toolkit/8.0.RC1.alpha002/python/site-packages/tbe/tikcpp/compile_op.py).. [ERROR] TBE(123105,python3):2025-06-23-23:33:18.348.498 [../../../opc_tool/opc.py:696][main] Opc tool compile failed. Opc tool start working now, please wait for a moment. /home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out/op_kernel/binary/ascend910b/bin/sigmoid_custom/SigmoidCustom_a3c9eb1f1b227778957282b95ed93786.json not generated! gmake[3]: *** [op_kernel/CMakeFiles/ascendc_bin_ascend910b_sigmoid_custom_0.dir/build.make:70: op_kernel/CMakeFiles/ascendc_bin_ascend910b_sigmoid_custom_0] Error 1 gmake[2]: *** [CMakeFiles/Makefile2:645: op_kernel/CMakeFiles/ascendc_bin_ascend910b_sigmoid_custom_0.dir/all] Error 2 gmake[2]: *** Waiting for unfinished jobs.... [ERROR] TBE(123103,python3):2025-06-23-23:33:18.302.945 [../../../opc_tool/opc_common.py:218][_log_error] Traceback (most recent call last): File "/home/ma-user/Ascend/ascend-toolkit/8.0.RC1.alpha002/python/site-packages/opc_tool/op_compilation.py", line 417, in get_op_func_attr opm = importlib.import_module(op_module) File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module [ERROR] TBE(123103,python3):2025-06-23-23:33:18.303.138 [../../../opc_tool/opc_common.py:218][_log_error] File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out/op_kernel/binary/ascend310b/src/SigmoidCustom.py", line 14, in <module> from tbe.tikcpp.compile_op import CommonUtility, AscendCLogLevel ImportError: cannot import name 'CommonUtility' from 'tbe.tikcpp.compile_op' (/home/ma-user/Ascend/ascend-toolkit/8.0.RC1.alpha002/python/site-packages/tbe/tikcpp/compile_op.py) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/ma-user/Ascend/ascend-toolkit/8.0.RC1.alpha002/python/site-packages/opc_tool/op_compilation.py", line 559, in single_op_compilation self.__op_compile_by_json_info(json_dict) [ERROR] TBE(123103,python3):2025-06-23-23:33:18.303.315 [../../../opc_tool/op_compilation.py:562][single_op_compilation] Compile failed, reason is: import src.SigmoidCustom error, reason:cannot import name 'CommonUtility' from 'tbe.tikcpp.compile_op' (/home/ma-user/Ascend/ascend-toolkit/8.0.RC1.alpha002/python/site-packages/tbe/tikcpp/compile_op.py).. [ERROR] TBE(123103,python3):2025-06-23-23:33:18.303.558 [../../../opc_tool/opc.py:696][main] Opc tool compile failed. Opc tool start working now, please wait for a moment. /home/ma-user/work/SigmoidCustom/SigmoidCustom/build_out/op_kernel/binary/ascend310b/bin/sigmoid_custom/SigmoidCustom_a3c9eb1f1b227778957282b95ed93786.json not generated! gmake[3]: *** [op_kernel/CMakeFiles/ascendc_bin_ascend310b_sigmoid_custom_0.dir/build.make:70: op_kernel/CMakeFiles/ascendc_bin_ascend310b_sigmoid_custom_0] Error 1 gmake[2]: *** [CMakeFiles/Makefile2:514: op_kernel/CMakeFiles/ascendc_bin_ascend310b_sigmoid_custom_0.dir/all] Error 2 gmake[1]: *** [CMakeFiles/Makefile2:416: op_kernel/CMakeFiles/binary.dir/rule] Error 2 gmake: *** [Makefile:306: binary] Error 2 [ERROR] Kernel compile failed, the run package will not be generated.
最新发布
06-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值