get_ctx
函数功能
DSL算子的运行平台为CPU时,用于获取算子运行的上下文。
函数原型
def get_ctx():
参数说明
无。
返回值
在CPU上运行的算子的上下文。
约束说明
无
调用示例
from tbe import tvm
from tbe import dsl
from tbe.common.utils import para_check
from tbe.common.utils import shape_util
# 引入testing模块相关接口
from tbe.common.testing import *
import numpy as np
#这边我们想模拟实现一个自定义算子,算子的数学表达式如下所示:
# C = A + B, D = C + B
# A,B是输入
# D是输出
# C是某个中间Tensor
def test_vadd_debug_api_test():
# 进入DSL调试模式
with debug():
# 选择CPU作为DSL的运行平台
ctx = get_ctx()
父主题: TBE DSL Testing API