MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / af_copy_array

Function af_copy_array

src/api/c/array.cpp:150–197  ·  view source on GitHub ↗

Strong Exception Guarantee

Source from the content-addressed store, hash-verified

148
149// Strong Exception Guarantee
150af_err af_copy_array(af_array *out, const af_array in) {
151 try {
152 const ArrayInfo &info = getInfo(in, false);
153 const af_dtype type = info.getType();
154
155 af_array res = 0;
156 if (info.isSparse()) {
157 const SparseArrayBase sbase = getSparseArrayBase(in);
158 if (info.ndims() == 0) {
159 return af_create_sparse_array_from_ptr(
160 out, info.dims()[0], info.dims()[1], 0, nullptr, nullptr,
161 nullptr, type, sbase.getStorage(), afDevice);
162 }
163 switch (type) {
164 case f32: res = copySparseArray<float>(in); break;
165 case f64: res = copySparseArray<double>(in); break;
166 case c32: res = copySparseArray<cfloat>(in); break;
167 case c64: res = copySparseArray<cdouble>(in); break;
168 default: TYPE_ERROR(0, type);
169 }
170
171 } else {
172 if (info.ndims() == 0) {
173 return af_create_handle(out, 0, nullptr, type);
174 }
175 switch (type) {
176 case f32: res = copyArray<float>(in); break;
177 case c32: res = copyArray<cfloat>(in); break;
178 case f64: res = copyArray<double>(in); break;
179 case c64: res = copyArray<cdouble>(in); break;
180 case b8: res = copyArray<char>(in); break;
181 case s32: res = copyArray<int>(in); break;
182 case u32: res = copyArray<uint>(in); break;
183 case s8: res = copyArray<schar>(in); break;
184 case u8: res = copyArray<uchar>(in); break;
185 case s64: res = copyArray<intl>(in); break;
186 case u64: res = copyArray<uintl>(in); break;
187 case s16: res = copyArray<short>(in); break;
188 case u16: res = copyArray<ushort>(in); break;
189 case f16: res = copyArray<half>(in); break;
190 default: TYPE_ERROR(1, type);
191 }
192 }
193 std::swap(*out, res);
194 }
195 CATCHALL
196 return AF_SUCCESS;
197}
198
199// Strong Exception Guarantee
200af_err af_get_data_ref_count(int *use_count, const af_array in) {

Callers 6

af_lookupFunction · 0.70
af_assign_seqFunction · 0.70
af_assign_genFunction · 0.70
initMethod · 0.50
toTempFormatFunction · 0.50
copyMethod · 0.50

Calls 8

swapFunction · 0.85
isSparseMethod · 0.80
getStorageMethod · 0.80
af_create_handleFunction · 0.70
getTypeMethod · 0.45
ndimsMethod · 0.45
dimsMethod · 0.45

Tested by 2

initMethod · 0.40
toTempFormatFunction · 0.40