is_tensorTrait
产品支持情况
产品 |
是否支持 |
---|---|
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
|
x |
功能说明
判断输入的数据结构是否为TensorTrait数据结构,可通过检查其成员常量value的值来判断。当value为true时,表示输入的数据结构是TensorTrait类型;反之则为非TensorTrait类型。
函数原型
template <typename T> struct is_tensorTrait
参数说明
参数名 |
描述 |
---|---|
T |
根据输入的数据类型,判断是否为TensorTrait数据结构。 |
返回值说明
无
约束说明
无
调用示例
1 2 3 4 5 6 7 8 9 10 11 12 | // 以下示例为基于googletest的UT示例 AscendC::Shape<int,int,int> shape = AscendC::MakeShape(10, 20, 30); AscendC::Stride<int,int,int> stride = AscendC::MakeStride(1, 100, 200); auto layoutMake = AscendC::MakeLayout(shape, stride); auto tensorTraitMake = AscendC::MakeTensorTrait<float, AscendC::TPosition::VECIN>(layoutMake); EXPECT_EQ(AscendC::is_tensorTrait<decltype(shape)>::value, false); EXPECT_EQ(AscendC::is_tensorTrait<decltype(stride)>::value, false); EXPECT_EQ(AscendC::is_tensorTrait<decltype(layoutMake)>::value, false); EXPECT_EQ(AscendC::is_tensorTrait<decltype(tensorTraitMake)>::value, true); |
父主题: TensorTrait