is_tensorTrait

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

x

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Determines whether an input data structure is of the TensorTrait type by checking the value of its member constant value. If value is true, the input data structure is of the TensorTrait type; otherwise, it is not.

Prototype

template <typename T> struct is_tensorTrait

Parameters

Parameter

Description

T

Whether the input data structure is of the TensorTrait type based on the input data type.

Returns

None

Restrictions

None

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
// The following is a unit test example based on GoogleTest.

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);