本文整理汇总了C++中SparseArray::eval方法的典型用法代码示例。如果您正苦于以下问题:C++ SparseArray::eval方法的具体用法?C++ SparseArray::eval怎么用?C++ SparseArray::eval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparseArray
的用法示例。
在下文中一共展示了SparseArray::eval方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sparseConvertStorageToStorage
SparseArray<T> sparseConvertStorageToStorage(const SparseArray<T> &in)
{
// Dummy function
// TODO finish this function when support is required
AF_ERROR("CPU Backend only supports Dense to CSR or COO", AF_ERR_NOT_SUPPORTED);
in.eval();
SparseArray<T> dense = createEmptySparseArray<T>(in.dims(), (int)in.getNNZ(), dest);
return dense;
}
示例2: sparseConvertStorageToDense
Array<T> sparseConvertStorageToDense(const SparseArray<T> &in_)
{
// MKL only has dns<->csr.
// CSR <-> CSC is only supported if input is square
if(stype == AF_STORAGE_CSC)
AF_ERROR("CPU Backend only supports Dense to CSR or COO", AF_ERR_NOT_SUPPORTED);
in_.eval();
Array<T> dense_ = createValueArray<T>(in_.dims(), scalar<T>(0));
dense_.eval();
auto func = [=] (Array<T> dense, const SparseArray<T> in) {
// Read: https://software.intel.com/en-us/node/520848
// But job description is incorrect with regards to job[1]
// 0 implies row major and 1 implies column major
int j1 = 1, j2 = 0;
const int job[] = {1, j1, j2, 2, (int)dense.elements(), 1};
const int M = dense.dims()[0];
const int N = dense.dims()[1];
int ldd = dense.strides()[1];
int info = 0;
Array<T > values = in.getValues();
Array<int> rowIdx = in.getRowIdx();
Array<int> colIdx = in.getColIdx();
// Have to mess up all const correctness because MKL dnscsr function
// is bidirectional and has input/output on all pointers
dnscsr_func<T>()(
job, &M, &N,
reinterpret_cast<ptr_type<T>>(dense.get()), &ldd,
reinterpret_cast<ptr_type<T>>(const_cast<T*>(values.get())),
const_cast<int*>(colIdx.get()),
const_cast<int*>(rowIdx.get()),
&info);
};
getQueue().enqueue(func, dense_, in_);
if(stype == AF_STORAGE_CSR)
return dense_;
else
AF_ERROR("CPU Backend only supports Dense to CSR or COO", AF_ERR_NOT_SUPPORTED);
return dense_;
}
示例3: sparseConvertCOOToDense
Array<T> sparseConvertCOOToDense(const SparseArray<T> &in)
{
in.eval();
Array<T> dense = createValueArray<T>(in.dims(), scalar<T>(0));
dense.eval();
const Array<T> values = in.getValues();
const Array<int> rowIdx = in.getRowIdx();
const Array<int> colIdx = in.getColIdx();
getQueue().enqueue(kernel::coo2dense<T>, dense, values, rowIdx, colIdx);
return dense;
}