static INLINE void define_rect(struct pipe_resource *pt, unsigned level, unsigned z, unsigned x, unsigned y, unsigned w, unsigned h, struct nv30_rect *rect) { struct nv30_miptree *mt = nv30_miptree(pt); struct nv30_miptree_level *lvl = &mt->level[level]; rect->w = u_minify(pt->width0, level) << mt->ms_x; rect->w = util_format_get_nblocksx(pt->format, rect->w); rect->h = u_minify(pt->height0, level) << mt->ms_y; rect->h = util_format_get_nblocksy(pt->format, rect->h); rect->d = 1; rect->z = 0; if (mt->swizzled) { if (pt->target == PIPE_TEXTURE_3D) { rect->d = u_minify(pt->depth0, level); rect->z = z; z = 0; } rect->pitch = 0; } else { rect->pitch = lvl->pitch; } rect->bo = mt->base.bo; rect->domain = NOUVEAU_BO_VRAM; rect->offset = layer_offset(pt, level, z); rect->cpp = util_format_get_blocksize(pt->format); rect->x0 = util_format_get_nblocksx(pt->format, x) << mt->ms_x; rect->y0 = util_format_get_nblocksy(pt->format, y) << mt->ms_y; rect->x1 = rect->x0 + (w << mt->ms_x); rect->y1 = rect->y0 + (h << mt->ms_y); }
neuron_range fc_rnn::get_neurons(layer_filter const& lfilter, neuron_filter const& nfilter) const { // TODO: Optimize by considering lfilter and nfilter together. // -> eg. only look for Input neurons within Input layer. neuron_iterator::data_array_t data; auto const NumLayerTypes = 3; auto const layer_types = std::array < LayerType, NumLayerTypes > { { LayerType::Input, LayerType::Hidden, LayerType::Output } }; // Iterate over our layers for(size_t ly = 0; ly < NumLayerTypes; ++ly) { // Construct layer data layer_data ld{ layer_types[ly] }; // And skip if doesn't pass layer filter if(!lfilter.test(ld)) { continue; } // Now iterate over neurons in the layer auto const start = layer_offset(layer_types[ly]); auto const end = start + layer_count(layer_types[ly]); for(auto id = start; id < end; ++id) { // And test against neuron filter auto nd = as_neuron_data(id); if(nfilter.test(nd)) { data.emplace_back(std::move(nd)); } } } return neuron_range( neuron_iterator(std::move(data)), neuron_iterator(), data.size() ); }
struct pipe_surface * nv30_miptree_surface_new(struct pipe_context *pipe, struct pipe_resource *pt, const struct pipe_surface *tmpl) { struct nv30_miptree *mt = nv30_miptree(pt); /* guaranteed */ struct nv30_surface *ns; struct pipe_surface *ps; struct nv30_miptree_level *lvl = &mt->level[tmpl->u.tex.level]; ns = CALLOC_STRUCT(nv30_surface); if (!ns) return NULL; ps = &ns->base; pipe_reference_init(&ps->reference, 1); pipe_resource_reference(&ps->texture, pt); ps->context = pipe; ps->format = tmpl->format; ps->usage = tmpl->usage; ps->u.tex.level = tmpl->u.tex.level; ps->u.tex.first_layer = tmpl->u.tex.first_layer; ps->u.tex.last_layer = tmpl->u.tex.last_layer; ns->width = u_minify(pt->width0, ps->u.tex.level); ns->height = u_minify(pt->height0, ps->u.tex.level); ns->depth = ps->u.tex.last_layer - ps->u.tex.first_layer + 1; ns->offset = layer_offset(pt, ps->u.tex.level, ps->u.tex.first_layer); if (mt->swizzled) ns->pitch = 4096; /* random, just something the hw won't reject.. */ else ns->pitch = lvl->pitch; /* comment says there are going to be removed, but they're used by the st */ ps->width = ns->width; ps->height = ns->height; return ps; }
connection_range fc_rnn::get_connections( layer_filter const& src_lfilter, layer_filter const& dst_lfilter, neuron_filter const& src_nfilter, neuron_filter const& dst_nfilter ) const { connection_iterator::data_array_t data; auto const src_layers = std::array < LayerType, 2 > { { LayerType::Input, LayerType::Hidden } }; auto const dst_layers = std::map< LayerType, std::array < LayerType, 2 > >{ { LayerType::Input, { { LayerType::Hidden, LayerType::Output } } }, { LayerType::Hidden, { { LayerType::Hidden, LayerType::Output } } } }; // Iterate over possible source layers for(auto ly_src : src_layers) { layer_data ld_src{ ly_src }; // Skip if don't pass layer filters if(!src_lfilter.test(ld_src)) { continue; } for(auto ly_dst : dst_layers.at(ly_src)) { layer_data ld_dst{ ly_dst }; // Skip if don't pass layer filters if(!dst_lfilter.test(ld_dst)) { continue; } // Now iterate over neurons in src layer auto const src_start = layer_offset(ly_src); auto const src_end = src_start + layer_count(ly_src); for(auto src_id = src_start; src_id < src_end; ++src_id) { // And test against src neuron filter auto src_nd = as_neuron_data(src_id); if(!src_nfilter.test(src_nd)) { continue; } // Neuron passed source filter, so iterate over dst neurons // TODO: should just test each neuron against src/dest filters once at most!! auto const dst_start = layer_offset(ly_dst); auto const dst_end = dst_start + layer_count(ly_dst); for(auto dst_id = dst_start; dst_id < dst_end; ++dst_id) { auto dst_nd = as_neuron_data(dst_id); if(dst_nfilter.test(dst_nd)) { auto const id = get_connection_id(src_id, dst_id); data.emplace_back(as_connection_data(id)); } } } } } return connection_range( connection_iterator(std::move(data)), connection_iterator(), data.size() ); }