本文整理汇总了C++中af::dim4::ndims方法的典型用法代码示例。如果您正苦于以下问题:C++ dim4::ndims方法的具体用法?C++ dim4::ndims怎么用?C++ dim4::ndims使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类af::dim4
的用法示例。
在下文中一共展示了dim4::ndims方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: channel_split
// Split a MxNx3 image into 3 separate channel matrices.
// Produce 3 channels if needed
static af_err channel_split(const af_array rgb, const af::dim4 &dims,
af_array *outr, af_array *outg, af_array *outb, af_array *outa)
{
try {
af_seq idx[4][3] = {{af_span, af_span, {0, 0, 1}},
{af_span, af_span, {1, 1, 1}},
{af_span, af_span, {2, 2, 1}},
{af_span, af_span, {3, 3, 1}}
};
if (dims[2] == 4) {
AF_CHECK(af_index(outr, rgb, dims.ndims(), idx[0]));
AF_CHECK(af_index(outg, rgb, dims.ndims(), idx[1]));
AF_CHECK(af_index(outb, rgb, dims.ndims(), idx[2]));
AF_CHECK(af_index(outa, rgb, dims.ndims(), idx[3]));
} else if (dims[2] == 3) {
AF_CHECK(af_index(outr, rgb, dims.ndims(), idx[0]));
AF_CHECK(af_index(outg, rgb, dims.ndims(), idx[1]));
AF_CHECK(af_index(outb, rgb, dims.ndims(), idx[2]));
} else {
AF_CHECK(af_index(outr, rgb, dims.ndims(), idx[0]));
}
} CATCHALL;
return AF_SUCCESS;
}
示例2:
void randnTest<unsigned char>(af::dim4 &dims)
{
if (noDoubleTests<unsigned char>()) return;
af_array outArray = 0;
ASSERT_EQ(AF_ERR_NOT_SUPPORTED, af_randn(&outArray, dims.ndims(), dims.get(), (af_dtype) af::dtype_traits<unsigned char>::af_type));
if(outArray != 0) af_destroy_array(outArray);
}
示例3: randnTest
void randnTest(af::dim4 &dims)
{
if (noDoubleTests<T>()) return;
af_array outArray = 0;
ASSERT_EQ(AF_SUCCESS, af_randn(&outArray, dims.ndims(), dims.get(), (af_dtype) af::dtype_traits<T>::af_type));
if(outArray != 0) af_destroy_array(outArray);
}
示例4: af_scale
af_err af_scale(af_array *out, const af_array in, const float scale0, const float scale1,
const dim_t odim0, const dim_t odim1, const af_interp_type method)
{
try {
ArrayInfo i_info = getInfo(in);
af::dim4 idims = i_info.dims();
dim_t _odim0 = odim0, _odim1 = odim1;
float sx, sy;
if(_odim0 == 0 || _odim1 == 0) {
DIM_ASSERT(2, scale0 != 0);
DIM_ASSERT(3, scale1 != 0);
sx = 1.f / scale0, sy = 1.f / scale1;
_odim0 = idims[0] / sx;
_odim1 = idims[1] / sy;
} else if (scale0 == 0 || scale1 == 0) {
DIM_ASSERT(4, odim0 != 0);
DIM_ASSERT(5, odim1 != 0);
sx = idims[0] / (float)_odim0;
sy = idims[1] / (float)_odim1;
} else {
sx = 1.f / scale0, sy = 1.f / scale1;
}
static float trans_mat[6] = {1, 0, 0,
0, 1, 0};
trans_mat[0] = sx;
trans_mat[4] = sy;
static af::dim4 tdims(3, 2, 1, 1);
af_array t = 0;
AF_CHECK(af_create_array(&t, trans_mat, tdims.ndims(), tdims.get(), f32));
AF_CHECK(af_transform(out, in, t, _odim0, _odim1, method, true));
AF_CHECK(af_release_array(t));
}
CATCHALL;
return AF_SUCCESS;
}
示例5: af_translate
af_err af_translate(af_array *out, const af_array in, const float trans0, const float trans1,
const dim_t odim0, const dim_t odim1, const af_interp_type method)
{
try {
static float trans_mat[6] = {1, 0, 0,
0, 1, 0};
trans_mat[2] = trans0;
trans_mat[5] = trans1;
static af::dim4 tdims(3, 2, 1, 1);
af_array t = 0;
AF_CHECK(af_create_array(&t, trans_mat, tdims.ndims(), tdims.get(), f32));
AF_CHECK(af_transform(out, in, t, odim0, odim1, method, true));
AF_CHECK(af_release_array(t));
}
CATCHALL;
return AF_SUCCESS;
}
示例6: af_skew
af_err af_skew(af_array *out, const af_array in, const float skew0, const float skew1,
const dim_t odim0, const dim_t odim1, const af_interp_type method,
const bool inverse)
{
try {
float tx = std::tan(skew0);
float ty = std::tan(skew1);
static float trans_mat[6] = {1, 0, 0,
0, 1, 0};
trans_mat[1] = ty;
trans_mat[3] = tx;
if(inverse) {
if(tx == 0 || ty == 0) {
trans_mat[1] = tx;
trans_mat[3] = ty;
} else {
//calc_tranform_inverse(trans_mat);
//short cut of calc_transform_inverse
float d = 1.0f / (1.0f - tx * ty);
trans_mat[0] = d;
trans_mat[1] = ty * d;
trans_mat[3] = tx * d;
trans_mat[4] = d;
}
}
static af::dim4 tdims(3, 2, 1, 1);
af_array t = 0;
AF_CHECK(af_create_array(&t, trans_mat, tdims.ndims(), tdims.get(), f32));
AF_CHECK(af_transform(out, in, t, odim0, odim1, method, true));
AF_CHECK(af_release_array(t));
}
CATCHALL;
return AF_SUCCESS;
}
示例7: ndims
size_t ndims() const { return dim_size.ndims(); }