profile和pstats是python代码的分析器,可以很客观查看代码的运行质量和使用的资源.在调试程序时有很大的帮助.
PST 训练阶段仅使用粗粒度注意力即可,推理时无需重新训练即可启用更精细的注意力,从而进一步提升精度。 这些结果充分证明,PST 是一种简单、硬件友好的通用增强方案,可无缝应用于检测与分类任务。 基于这一共识,我们提出了 Pyramid Sparse Transformer(PST)。 通过让富含语义的高层 token 引导对低层细节的关注,PST 在减少 token 交互的同时提升了上下文对齐性与判别力。 图 2:Pyramid Sparse Transformer(PST)整体结构。 左:PST 以相邻两层特征图为输入,用我们提出的 Pyramid Sparse Attention(PSA) 块替换标准注意力。
pst->capacity = 0; } void stackdestory(stack* pst) { assert(pst); free(pst->a); pst->a = NULL; pst->top = 0; pst->capacity = 0; } void stackpush(stack* pst, sldatatype x) { if (pst->top == pst ; return; } pst->a = temp; pst->capacity = newcapacity; } pst->a[pst->top] = x; pst->top+ stackempty(pst)); return pst->a[pst->top - 1]; } bool stackempty(stack* pst) { assert(pst); return (stack* pst) { assert(pst); free(pst->a); pst->a = NULL; pst->top = 0; pst->capacity = 0; } void
void STPush(ST* pst, STDataType x) { assert(pst); if (pst->top == pst->capacity) { int newcapacity ; return; } pst->a = tmp; pst->capacity = newcapacity; } pst->a[pst->top] = x; pst->top++ ); free(pst->a); pst->a = NULL; pst->top = pst->capacity = 0; } // 栈顶插入删除 void STPush(ST* pst, STDataType ; return; } pst->a = tmp; pst->capacity = newcapacity; } pst->a[pst->top] = x; pst->top++ STDataType STTop(ST* pst) { assert(pst); //不为空 assert(pst->top > 0); return pst->a[pst->top - 1]
pst); 7.获取栈大小 int STSize(ST* pst); 2.详细解析 1.栈的初始化 void STInit(ST* pst) { assert(pst); pst->a 2.释放了动态数组中的空间 void STDestroy(ST* pst) { assert(pst); free(pst->a); pst->a = NULL; pst->top = pst STDataType STTop(ST* pst) { assert(pst); // 不为空 assert(pst->top > 0); return pst->a[pst->top - 1 (ST* pst) { assert(pst); pst->a = NULL; pst->capacity = 0; // 表示top指向栈顶元素的下一个位置 pst->top = 0; // 表示top指向栈顶元素 //pst->top = -1; } void STDestroy(ST* pst) { assert(pst); free(pst->a); pst->a
销毁 void STDestroy(ST* pst) { assert(pst); free(pst->a); pst->a = NULL; pst->top = pst->capacity = (ST* pst) { assert(pst); return pst->top == 0; } top为0栈就为空 获取数据个数 int STSize(ST* pst) { assert(pst STInit(ST* pst) { assert(pst); pst->a = NULL; //top指向栈顶数据的下一个位置 pst->top = 0; //top指向栈顶数据 //pst = newcapcity; } pst->a[pst->top] = x; pst->top++; } void STPop(ST* pst) { assert(pst); assert(pst return pst->a[pst->top - 1]; } //判空 bool STEmpty(ST* pst) { assert(pst); return pst->top == 0; }
) { assert(pst); pst->arr = NULL; pst->top = pst->capacity = 0; } //入栈 void stack_push(stack* pst ] = x; pst->top++; } //出栈 void stack_pop(stack* pst) { assert(pst); assert(pst->top > 0); pst->top ->arr[pst->top-1]; } //销毁 void stack_destroy(stack* pst) { assert(pst); free(pst->arr); pst->arr = NULL; pst->capacity = pst->top = 0; } //判空 bool stack_empty(stack* pst) { assert(pst); return pst ) { assert(pst); pst->arr = NULL; pst->top = pst->capacity = 0; } //入栈 void stack_push(stack* pst
下面给出需要的栈的函数: void STInit(ST* pst) { assert(pst); pst->a = NULL; pst->capacity = 0; pst->top = 0; //pst->top = -1; } void STDestroy(ST* pst) { free(pst->a); pst->a = NULL; pst->capacity = pst-> newcapacity; } pst->a[pst->top] = x; pst->top++; } void STPop(ST* pst) { assert(pst); assert(pst ->top > 0); pst->top--; } STDataType STTop(ST* pst) { assert(pst); assert(pst->top > 0); return pst->a[pst->top - 1]; } bool STEmpty(ST* pst) { assert(pst); //if (pst->top == 0) //{ // return
(pst); pst->stack = NULL; pst->top = 0; pst->capacity = 0; } //判断是否为空栈 bool STIsEmpty (pst); //检查容量 if (pst->top == pst->capacity) { int len = pst->capacity == 0 ? STIsEmpty(pst)); pst->top--; } //获取栈顶的元素 STDataType STTop(ST* pst) { assert(pst); STIsEmpty(pst)); return pst->stack[pst->top - 1]; } //销毁栈 void STDestroy(ST* pst) { assert(pst); free(pst->stack); pst->stack = NULL; pst->capacity = pst->top = 0; }
(ST* pst) { assert(pst); free(pst->a); pst->a = NULL; pst->top = pst->capacity = 0; } //容量检查 void Checkcapacity(ST* pst) { assert(pst); if (pst->top == pst->capacity) { int newcapacity = pst->capacity ; } } //入栈和出栈 void STPush(ST* pst, datatype x) { assert(pst); Checkcapacity(pst); pst->a[pst->top ] = x; pst->top++; } void STPop(ST* pst) { assert(pst); assert(pst->top>0); pst->top--; } //获取栈顶数据 datatype STTop(ST* pst) { assert(pst); assert(pst->top > 0); return pst->a[pst->top-1]; } //判空 bool
pst->capacity = newCapacity;//把扩容后的空间大小赋值给栈容量 } pst->a[pst->top] = x;//先放值 pst->top++;//再++ } 4 STEmpty(pst)); pst->top--; } 6.获取栈顶元素 STDataType STTop(ST* pst) { assert(pst); assert(! STEmpty(pst)); return pst->a[pst->top - 1]; } 7.获取栈中有效元素个数 int STSize(ST* pst) { assert(pst); return " void STInit(ST* pst) { assert(pst); pst->a = NULL;//栈底 //top不是下标 //pst->top=-1;//指向栈顶元素 pst STEmpty(pst)); pst->top--; } STDataType STTop(ST* pst) { assert(pst); assert(!
++; pst->_arr[pst->_top] = data; } void StackPop(Stack* pst) { assert(pst); //确保栈里面有元素 assert(pst // 销毁栈 void StackDestroy(Stack* pst) { assert(pst); free(pst->_arr); pst->_arr = NULL; pst->_top (Stack* pst) { StackInit(pst); StackPush(pst,1); printf("%d\n", StackTop(pst)); StackPush(pst,2); (pst)); StackPop(pst); printf("%d\n", StackTop(pst)); StackPop(pst); printf("%d\n", StackTop(pst) (Stack* pst) { assert(pst); free(pst->_arr); pst->_arr = NULL; pst->_top = -1; pst->_capacity =
STEmpty(ST* pst); //获取数据个数 int STSize(ST* pst); void STInit(ST* pst) { assert(pst); pst->a = NULL ; //指向栈顶数据的下一个位置 pst->top = 0; pst->capacity = 0; } void Destroy(ST* pst) { assert(pst); free(pst assert(pst); if (pst->capacity == pst->top) { int newCapacity = pst->capacity==0 ? newCapacity; } pst->a[pst->top] = x; pst->top++; } void STPop(ST* pst) { assert(pst); assert(pst pst->a[pst->top-1]; } //判空 bool STEmpty(ST* pst) { assert(pst); return pst->top == 0; } int STSize
我们来实现一下栈的初始化函数: void STInit(ST* pst) { assert(pst); pst->a = NULL; pst->capacity = 0; pst->top = 我们来实现一下栈的销毁: void STDestroy(ST* pst) { assert(pst); free(pst->a); pst->a = NULL; pst->top = pst-> 我们来实现一下获取栈顶元素的函数: STDatatype STTop(ST* pst) { assert(pst); assert(pst->top > 0); return pst->a[pst pst) { assert(pst); return pst->top; } int STEmpty(ST* pst) { assert(pst); return pst->top == 0; } void STDestroy(ST* pst) { assert(pst); free(pst->a); pst->a = NULL; pst->top = pst->capacity =
STInit(ST* pst) { assert(pst); pst->a = NULL; pst->capacity = 0; pst->top = 0; } //销毁 void STDestroy (ST* pst) { assert(pst); free(pst->a); pst->a = NULL; pst->top = pst->capacity = 0; } //入栈 void STPush newcapacity; } pst->a[pst->top] = x; pst->top++; } //出栈 void STPop(ST* pst) { assert(pst); assert (pst->top > 0); pst->top--; } //返回栈顶元素 STDataType STTop(ST* pst) { assert(pst); assert(pst->top > 0); return pst -> a[pst->top - 1]; } //判空 bool STEmpty(ST* pst) { assert(pst); /*if (pst->top == 0
STInit(ST* pst) { assert(pst); pst->a = NULL; pst->capacity = 0; pst->top = 0; } //销毁 void STDestroy (ST* pst) { assert(pst); free(pst->a); pst->a = NULL; pst->top = pst->capacity = 0; } //入栈 void STPush newcapacity; } pst->a[pst->top] = x; pst->top++; } //出栈 void STPop(ST* pst) { assert(pst); assert (pst->top > 0); pst->top--; } //返回栈顶元素 STDataType STTop(ST* pst) { assert(pst); assert(pst->top > 0); return pst -> a[pst->top - 1]; } //判空 bool STEmpty(ST* pst) { assert(pst); /*if (pst->top == 0
) { assert(pst); pst->a = NULL; pst->capacity = 0; // 表示top指向栈顶元素的下一个位置 pst->top = 0; // 表示top 指向栈顶元素 //pst->top = -1; } 销毁 void STDestroy(ST* pst) { assert(pst); free(pst->a); pst->a = NULL; pst->top = pst->capacity = 0; } 压栈 压栈的时候需要先判断栈满不满,判断条件pst->top == pst->capacity 如果满了,则需要开辟空间 不满则直接压入栈顶即可 , STDataType x) { assert(pst); if (pst->top == pst->capacity) { int newcapacity = pst->capacity int STSize(ST* pst) { assert(pst); return pst->top; }
= -1); return pst->a[pst->top]; } 判断是否为空 bool STEmpty(ST* pst) { assert(pst); if (pst->top == -1) 销毁 void STDestroy(ST* pst) { assert(pst); free(pst->a); pst->a = NULL; pst->capacity = 0; pst->top (ST* pst) { assert(pst);//防止结构体为空 pst->a = NULL; pst->capacity = 0; pst->top = -1; } // 栈顶插入删除 newcapacity; } pst->top++; pst->a[pst->top] = x; } void STPop(ST* pst) { assert(pst); pst->top- (ST* pst) { assert(pst); free(pst->a); pst->a = NULL; pst->capacity = 0; pst->top = -1; } test.c
每个磁盘的AU 1是为PST表预留的,但是并不是每一个磁盘都有PST表的信息。 PST count 在external冗余的磁盘组中只有一份PST表。 在normal冗余的磁盘组中,至少有两份PST表。如果磁盘组中有三个或更多的failgroups,PST表将会有3份。 在high冗余的磁盘组中,至少有三份PST表的信息。 如果有四个failgroups,将会有4份PST表,如果有五个或者更多failgroups,将会有五份PST表。 PST relocation PST在下列情况下会再分配: ● PST所在磁盘不可用(ASM实例启动时) ● 磁盘offline ● PST的读写发生IO错误 ● 磁盘被正常的删除掉(手工或后台 --- HDR ---标记的部分显示了PST的副本数(pst count)和所在的磁盘号。--- DTA ---显示了PST所在磁盘的状态。
* pst); 1.2.2 -> Stack.c #include "Stack.h" // 栈的初始化 void STInit(ST* pst) { assert(pst); pst->a = NULL; pst->top = 0; pst->capacity = 0; } // 栈的销毁 void STDestroy(ST* pst) { assert(pst); free(pst = newCapacity; } pst->a[pst->top] = x; pst->top++; } // 出栈 void STPop(ST* pst) { assert(pst); STEmpty(pst)); pst->top--; } // 获取栈顶元素 STDataType STTop(ST* pst) { assert(pst); assert(! STEmpty(pst)); return pst->a[pst->top - 1]; } // 判空 bool STEmpty(ST* pst) { assert(pst); return