Exemplo n.º 1
0
		void dump(FILE* fp, int32_t level)
		{
			std::string str;

			if (level == 0)
				fprintf(fp, "\n");

			str.append(level * 4, ' ');

			fprintf(fp, "%s%d times, total ", str.c_str(), m_times);
			out_size(fp, m_sz);

			str.append(4, ' ');
			fprintf(fp, "%s", str.c_str());

			out_proc(fp, proc);

			caller* p = this;
			while (p->subs.size() == 1)
			{
				p = p->subs[0];
				fprintf(fp, "%s", str.c_str());
				out_proc(fp, p->proc);
			}

			if (p && p->subs.size() > 0)
				p->dumpSubs(fp, level + 1);
		}
Exemplo n.º 2
0
static void print_embedded_files(poppler::document *doc)
{
    std::cout << "Document embedded files:" << std::endl;
    std::vector<poppler::embedded_file *> ef = doc->embedded_files();
    if (!ef.empty()) {
        std::vector<poppler::embedded_file *>::const_iterator it = ef.begin(), it_end = ef.end();
        const std::ios_base::fmtflags f = std::cout.flags();
        std::left(std::cout);
        for (; it != it_end; ++it) {
            poppler::embedded_file *f = *it;
            std::cout
                << " " << std::setw(out_width + 10) << f->name()
                << " " << std::setw(10) << out_size(f->size())
                << " " << std::setw(20) << out_date(f->creation_date())
                << " " << std::setw(20) << out_date(f->modification_date())
                << std::endl
                << "     ";
            if (f->description().empty()) {
                std::cout << "<no description>";
            } else {
                std::cout << f->description();
            }
            std::cout
                << std::endl
                << "     " << std::setw(35) << (f->checksum().empty() ? std::string("<no checksum>") : out_hex_string(f->checksum()))
                << " " << (f->mime_type().empty() ? std::string("<no mime type>") : f->mime_type())
                << std::endl;
        }
        std::cout.flags(f);
    } else {
        std::cout << "<no embedded files>" << std::endl;
    }
    std::cout << std::endl;
}
Exemplo n.º 3
0
void SpatialLPPooling::init(std::shared_ptr<TorchData> input) {
  RASSERT(input->type() == TorchDataType::TENSOR_DATA);
  Tensor<float>* in = TO_TENSOR_PTR(input.get());
  RASSERT(in->dim() == 2 || in->dim() == 3);

  if (output != nullptr && TO_TENSOR_PTR(output.get())->dim() != in->dim()) {
    // Input dimension has changed!
    cleanup();
  }

  if (output != nullptr) {
    // Check that the dimensions above the lowest 2 match
    for (uint32_t i = 2; i < in->dim() && output != nullptr; i++) {
      if (TO_TENSOR_PTR(output.get())->size()[i] != in->size()[i]) {
        cleanup();
      }
    }
  }

  if (output != nullptr) {
    // Check that the lowest 2 dimensions are the correct size
    if (TO_TENSOR_PTR(output.get())->size()[0] != in->size()[0] / poolsize_u_ ||
        TO_TENSOR_PTR(output.get())->size()[1] != in->size()[1] / poolsize_v_) {
      cleanup();
    }
  }

  if (output == nullptr) {
    // Check that the width and height is a multiple of the poolsize
    RASSERT(in->size()[0] % poolsize_u_ == 0 &&
           in->size()[1] % poolsize_v_ == 0);

    std::unique_ptr<uint32_t[]> out_size(new uint32_t[in->dim()]);
    out_size[0] = in->size()[0] / poolsize_u_;
    out_size[1] = in->size()[1] / poolsize_v_;
    for (uint32_t i = 2; i < in->dim(); i++) {
      out_size[i] = in->size()[i];
    }

    output.reset(new Tensor<float>(in->dim(), out_size.get()));
    input_cpu_.reset(new float[in->nelems()]);
    output_cpu_.reset(new float[TO_TENSOR_PTR(output.get())->nelems()]);
  }

  uint32_t n_threads = 1;
  if (in->dim() > 2) {
    n_threads = TO_TENSOR_PTR(output.get())->size()[2];
  }
  if (thread_cbs_.size() != n_threads) {
    thread_cbs_.empty();
    for (uint32_t f = 0; f < n_threads; f++) {
      thread_cbs_.push_back(std::unique_ptr<jcl::threading::Callback<void>>(
          MakeCallableMany(&SpatialLPPooling::forwardPropThread, this, f)));
    }
  }
}
Exemplo n.º 4
0
static int _striped_text_export(const struct lv_segment *seg, struct formatter *f)
{

	outf(f, "stripe_count = %u%s", seg->area_count,
	     (seg->area_count == 1) ? "\t# linear" : "");

	if (seg->area_count > 1)
		out_size(f, (uint64_t) seg->stripe_size,
			 "stripe_size = %u", seg->stripe_size);

	return out_areas(f, seg, "stripe");
}
Exemplo n.º 5
0
static int _mirrored_text_export(const struct lv_segment *seg, struct formatter *f)
{
        outf(f, "mirror_count = %u", seg->area_count);
        if (seg->status & PVMOVE)
                out_size(f, (uint64_t) seg->extents_copied * seg->lv->vg->extent_size,
                         "extents_moved = %" PRIu32, seg->extents_copied);
        if (seg->log_lv)
                outf(f, "mirror_log = \"%s\"", seg->log_lv->name);
        if (seg->region_size)
                outf(f, "region_size = %" PRIu32, seg->region_size);

        return out_areas(f, seg, "mirror");
}
Exemplo n.º 6
0
void photoalbum::api::map::map_tile_km(
        const jsonrpc::request& request,
        jsonrpc::result&        result,
        sqlite::connection&     conn
        )
{
    const std::string region = request.params().get<std::string>(0);
    const int eastings = request.params().get<int>(1);
    const int northings = request.params().get<int>(2);

    photoalbum::map::tile_data_db data_db;
    db::get(
            conn,
            region,
            eastings/10,
            northings/10,
            data_db
            );
    try
    {
        Magick::Image image(Magick::Blob(
            reinterpret_cast<const void*>(&(data_db.data[0])),
            data_db.data.size()
            )
            );
        Magick::Geometry out_size(
            image.size().width()/5,
            image.size().height()/5
            );
        Magick::Image out_image(out_size, Magick::Color(255,255,255));

        int off_x = -(out_size.width() * (eastings%5));
        int off_y = -(out_size.height() * (4 - (northings%5)));
        out_image.composite(image, off_x, off_y);

        Magick::Blob blob;
        out_image.write(&blob, "PNG");
        png_data(result.data()).data() = base64::encode(
            reinterpret_cast<const unsigned char*>(blob.data()),
            blob.length()
            );
    }
    catch(const std::exception& e)
    {
    }
}
Exemplo n.º 7
0
void SpatialMaxPooling::init(std::shared_ptr<TorchData> input) {
  RASSERT(input->type() == TorchDataType::TENSOR_DATA);
  Tensor<float>* in = TO_TENSOR_PTR(input.get());
  RASSERT(in->dim() == 2 || in->dim() == 3);

  // We'll escentially do ceil_mode = false from torch
  const uint32_t iwidth = in->size()[0];
  const uint32_t iheight = in->size()[1];
  uint32_t oheight = (long)(floor((float)(iheight - kh_ + 2*padh_) / dh_)) + 1;
  uint32_t owidth  = (long)(floor((float)(iwidth  - kw_ + 2*padw_) / dw_)) + 1;

  if (output != nullptr && TO_TENSOR_PTR(output.get())->dim() != in->dim()) {
    // Input dimension has changed!
    output = nullptr;
  }

  if (output != nullptr) {
    // Check that the dimensions above the lowest 2 match
    for (uint32_t i = 2; i < in->dim() && output != nullptr; i++) {
      if (TO_TENSOR_PTR(output.get())->size()[i] != in->size()[i]) {
        output = nullptr;
      }
    }
  }

  if (output != nullptr) {
    // Check that the lowest 2 dimensions are the correct size
    if (TO_TENSOR_PTR(output.get())->size()[0] != owidth ||
        TO_TENSOR_PTR(output.get())->size()[1] != oheight) {
      output = nullptr;
    }
  }

  if (output == nullptr) {
    std::unique_ptr<uint32_t[]> out_size(new uint32_t[in->dim()]);
    out_size[0] = owidth;
    out_size[1] = oheight;
    for (uint32_t i = 2; i < in->dim(); i++) {
      out_size[i] = in->size()[i];
    }
    output.reset(new Tensor<float>(in->dim(), out_size.get()));
  }
}
Exemplo n.º 8
0
	void dump()
	{
		Item* items;
		Item* p;
		int32_t n = 0;
		int32_t i;
		char fname[32];

		init_lib();

		m_lock.lock();
		items = (Item*)__real_malloc(sizeof(Item) * m_list.count());

		p = m_list.head();
		while (p)
		{
			memcpy(items + n ++, p, sizeof(Item));
			p = m_list.next(p);
		}
		m_lock.unlock();

		caller root(0);
		for (i = 0; i < n; i ++)
			root.put(items[i].m_sz, items[i].m_frames, items[i].m_frame_count);

		sprintf(fname, "fibjs.%d.heap", getpid());
		FILE* fp = fopen(fname, "w");
		if (fp)
		{
			fprintf(fp, "\nfound %d times, total ", root.m_times);
			out_size(fp, root.m_sz);
			root.dumpSubs(fp);
			fclose(fp);
		}

		__real_free(items);
	}
Exemplo n.º 9
0
void Inst::write_graph_rec( Vec<const Inst *> &ext_buf, Stream &os ) const {
    if ( op_id_vis == cur_op_id )
        return;
    op_id_vis = cur_op_id;

    // label
    std::ostringstream ss;
    write_dot( ss );

    // node
    std::string ls = ss.str();
    os << "    node" << this << " [label=\"";
    for( unsigned i = 0; i < ls.size(); ++i ) {
        switch ( ls[ i ] ) {
        case '<':
        case '>':
        case '\\':
            os << '\\';
        }
        os << ls[ i ];
    }
    if ( full_dot ) {
        if ( out_size() > 1 )
            for( int i = 0; i < out_size(); ++i )
                os << "|<f" << i << ">o";
        if ( inp_size() > 1 )
            for( int i = 0; i < inp_size(); ++i )
                os << "|<f" << out_size() + i << ">i";
    }
    os << "\"];\n";

    // children
    for( int i = 0, n = inp_size(); i < n; ++i ) {
        const Expr &ch = inp_expr( i );
        if ( full_dot ) {
            os << "    node" << this;
            if ( inp_size() > 1 )
                os << ":f" << out_size() + i;
            os << " -> node" << ch.inst.ptr();
            if ( ch.inst->out_size() > 1 )
                os << ":f" << ch.nout;
            os << ";\n";
        } else
            os << "    node" << this << " -> node" << ch.inst.ptr() << ";\n";

        if ( ch.inst )
            ch.inst->write_graph_rec( ext_buf, os );
    }

    // ext
    for( int i = 0, n = ext_size_disp(); i < n; ++i )
        if ( const Inst *ch = ext_inst( i ) )
            ext_buf << ch;

    // parents
    //    for( int nout = 0; nout < out_size(); ++nout ) {
    //        VPar &p = parents( nout );
    //        for( int i = 0; i < p.size(); ++i ) {
    //            os << "    node" << p[ i ] << " -> node" << this << ":f" << nout << " [color=\"red\"];\n";
    //            // parents[ i ]->write_graph_rec( ext_buf, os );
    //        }
    //    }
}