本文整理汇总了C++中type::get_as_strided方法的典型用法代码示例。如果您正苦于以下问题:C++ type::get_as_strided方法的具体用法?C++ type::get_as_strided怎么用?C++ type::get_as_strided使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类type
的用法示例。
在下文中一共展示了type::get_as_strided方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: broadcast_error
intptr_t ndt::fixed_dim_type::make_assignment_kernel(
const arrfunc_type_data *self, const arrfunc_type *af_tp, void *ckb,
intptr_t ckb_offset, const type &dst_tp, const char *dst_arrmeta,
const type &src_tp, const char *src_arrmeta, kernel_request_t kernreq,
const eval::eval_context *ectx, const nd::array &kwds) const
{
if (this == dst_tp.extended()) {
const fixed_dim_type_arrmeta *dst_md =
reinterpret_cast<const fixed_dim_type_arrmeta *>(dst_arrmeta);
intptr_t src_size, src_stride;
type src_el_tp;
const char *src_el_arrmeta;
if (src_tp.get_ndim() < dst_tp.get_ndim()) {
src_stride = 0;
nd::functional::elwise_ck<fixed_dim_type_id, fixed_dim_type_id, 1>::make(
ckb, kernreq, ckb_offset, get_fixed_dim_size(), dst_md->stride,
&src_stride);
return ::make_assignment_kernel(
self, af_tp, ckb, ckb_offset, m_element_tp,
dst_arrmeta + sizeof(fixed_dim_type_arrmeta), src_tp, src_arrmeta,
kernel_request_strided, ectx, kwds);
} else if (src_tp.get_as_strided(src_arrmeta, &src_size, &src_stride,
&src_el_tp, &src_el_arrmeta)) {
nd::functional::elwise_ck<fixed_dim_type_id, fixed_dim_type_id, 1>::make(
ckb, kernreq, ckb_offset, get_fixed_dim_size(), dst_md->stride,
&src_stride);
// Check for a broadcasting error
if (src_size != 1 && get_fixed_dim_size() != src_size) {
throw broadcast_error(dst_tp, dst_arrmeta, src_tp, src_arrmeta);
}
return ::make_assignment_kernel(
self, af_tp, ckb, ckb_offset, m_element_tp,
dst_arrmeta + sizeof(fixed_dim_type_arrmeta), src_el_tp,
src_el_arrmeta, kernel_request_strided, ectx, kwds);
} else if (!src_tp.is_builtin()) {
// Give the src type a chance to make a kernel
return src_tp.extended()->make_assignment_kernel(
self, af_tp, ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp,
src_arrmeta, kernreq, ectx, kwds);
} else {
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
} else if (dst_tp.get_kind() == string_kind) {
return make_any_to_string_assignment_kernel(ckb, ckb_offset, dst_tp,
dst_arrmeta, src_tp,
src_arrmeta, kernreq, ectx);
} else if (dst_tp.get_ndim() < src_tp.get_ndim()) {
throw broadcast_error(dst_tp, dst_arrmeta, src_tp, src_arrmeta);
} else {
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
}
示例2: make_broadcast_to_var_dim_assignment_kernel
intptr_t ndt::var_dim_type::make_assignment_kernel(void *ckb, intptr_t ckb_offset, const type &dst_tp,
const char *dst_arrmeta, const type &src_tp, const char *src_arrmeta,
kernel_request_t kernreq, const eval::eval_context *ectx) const
{
if (this == dst_tp.extended()) {
intptr_t src_size, src_stride;
type src_el_tp;
const char *src_el_arrmeta;
if (src_tp.get_ndim() < dst_tp.get_ndim()) {
// If the src has fewer dimensions, broadcast it across this one
return make_broadcast_to_var_dim_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta,
kernreq, ectx);
} else if (src_tp.get_type_id() == var_dim_type_id) {
// var_dim to var_dim
return make_var_dim_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq, ectx);
} else if (src_tp.get_as_strided(src_arrmeta, &src_size, &src_stride, &src_el_tp, &src_el_arrmeta)) {
// strided_dim to var_dim
return make_strided_to_var_dim_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_size, src_stride,
src_el_tp, src_el_arrmeta, kernreq, ectx);
} else if (!src_tp.is_builtin()) {
// Give the src type a chance to make a kernel
return src_tp.extended()->make_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta,
kernreq, ectx);
} else {
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
} else if (dst_tp.get_kind() == string_kind) {
return make_any_to_string_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq,
ectx);
} else if (dst_tp.get_ndim() < src_tp.get_ndim()) {
throw broadcast_error(dst_tp, dst_arrmeta, src_tp, src_arrmeta);
} else {
if (dst_tp.get_type_id() == fixed_dim_type_id) {
// var_dim to fixed_dim
return make_var_to_fixed_dim_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq,
ectx);
} else {
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
}
}