Exemplo n.º 1
0
HGLOBAL CCmdLog::CopyLog(int row)
{
	LPLOGGER plog = nullptr; int count = 0; int i;
	if (m_Table.mode & TABLE_STDSCR) {
		for (i = 0; ; ++i, count += plog->rows) {
			plog = reinterpret_cast<LPLOGGER> (
				Getsortedbyselection(&m_Table.sorted, i)
			);
			if (plog == nullptr) return nullptr;
			if (i != row) continue;
			m_Table.mode &= ~TABLE_STDSCR;
			HGLOBAL hMem = CopyRow(count, plog->rows);
			m_Table.mode |=  TABLE_STDSCR;
			return hMem;
		}
	} else {
		for (i = 0; ; ++i, count += plog->rows) {
			plog = reinterpret_cast<LPLOGGER> (
				Getsortedbyselection(&m_Table.sorted, i)
			);
			if (plog == nullptr) return nullptr;
			int end = count+static_cast<int>(plog->rows);
			if (row >= count && row < end) {
				return CopyRow(count, plog->rows);
			}
		}
	}
	// It should not be run here ..
	return nullptr;
}
Exemplo n.º 2
0
HGLOBAL CCmdLog::CopyTab(void)
{
	if (m_Table.mode & TABLE_STDSCR) {
		return CopyRow(0, m_Table.sorted.n);
	} else return CopyRow(0, m_Table.custommode);
}
Exemplo n.º 3
0
        void Trainer::CopyParameter(std::vector<int>& input_nodes,
            std::vector<int>& output_nodes)
        {
            //Compute the number of necessary memory blocks to store parameter
            std::vector<real*> blocks;
            int current_block = 0;
            size_t total_blocks = (input_nodes.size() + output_nodes.size());
            if (option_->use_adagrad)
                total_blocks *= 2;

            //Request blocks to store parameters
            memory_mamanger_->RequestBlocks(total_blocks, blocks);
            assert(blocks.size() == total_blocks);
            if (blocks.size() != total_blocks)
            {
                multiverso::Log::Error("Rank %d Trainer %d Error to requestBlocks to CopyParameter, allocated_blocks_num=%lld, needed_blocks_num=%lld\n",
                    multiverso::Multiverso::ProcessRank(), trainer_id_, blocks.size(), total_blocks);
                return;
            }

            //Copy input-embedding weights from multiverso to WordEmbedding
            for (int i = 0; i < input_nodes.size(); ++i)
            {
                real* ptr = blocks[current_block++];
                assert(ptr != nullptr);
                CopyRow(ptr, GetRow<real>(kInputEmbeddingTableId,
                    input_nodes[i]), option_->embeding_size);

                WordEmbedding_->SetWeightIE(input_nodes[i], ptr);
            }

            //Copy embedding-output weights from multiverso to WordEmbedding
            for (int i = 0; i < output_nodes.size(); ++i)
            {
                real* ptr = blocks[current_block++];
                assert(ptr != nullptr);
                CopyRow(ptr, GetRow<real>(kEmbeddingOutputTableId,
                    output_nodes[i]), option_->embeding_size);

                WordEmbedding_->SetWeightEO(output_nodes[i], ptr);
            }

            if (option_->use_adagrad)
            {
                //Copy input-embedding sum of squarsh of gradient 
                for (int i = 0; i < input_nodes.size(); ++i)
                {
                    real* ptr = blocks[current_block++];
                    assert(ptr != nullptr);
                    CopyRow(ptr, GetRow<real>(kSumGradient2IETableId,
                        input_nodes[i]), option_->embeding_size);

                    WordEmbedding_->SetSumGradient2IE(input_nodes[i], ptr);
                }

                //Copy embedding-output sum of squarsh of gradient 
                for (int i = 0; i < output_nodes.size(); ++i)
                {
                    real* ptr = blocks[current_block++];
                    assert(ptr != nullptr);
                    CopyRow(ptr, GetRow<real>(kSumGradient2EOTableId,
                        output_nodes[i]), option_->embeding_size);

                    WordEmbedding_->SetSumGradient2EO(output_nodes[i], ptr);
                }
            }
        }
Exemplo n.º 4
0
void nsRegion::SimplifyOutwardByArea(uint32_t aThreshold)
{

  pixman_box32_t *boxes;
  int n;
  boxes = pixman_region32_rectangles(&mImpl, &n);

  // if we have no rectangles then we're done
  if (!n)
    return;

  pixman_box32_t *end = boxes + n;
  pixman_box32_t *topRectsEnd = boxes+1;
  pixman_box32_t *topRects = boxes;

  // we need some temporary storage for merging both rows of rectangles
  nsAutoTArray<pixman_box32_t, 10> tmpStorage;
  tmpStorage.SetCapacity(n);
  pixman_box32_t *tmpRect = tmpStorage.Elements();

  pixman_box32_t *destRect = boxes;
  pixman_box32_t *rect = tmpRect;
  // find the end of the first span of rectangles
  while (topRectsEnd < end && topRectsEnd->y1 == topRects->y1) {
    topRectsEnd++;
  }

  // if we only have one row we are done
  if (topRectsEnd == end)
    return;

  pixman_box32_t *bottomRects = topRectsEnd;
  pixman_box32_t *bottomRectsEnd = bottomRects+1;
  do {
    // find the end of the bottom span of rectangles
    while (bottomRectsEnd < end && bottomRectsEnd->y1 == bottomRects->y1) {
      bottomRectsEnd++;
    }
    uint32_t totalArea = ComputeMergedAreaIncrease(topRects, topRectsEnd,
                                                   bottomRects, bottomRectsEnd);

    if (totalArea <= aThreshold) {
      // merge the rects into tmpRect
      rect = MergeRects(topRects, topRectsEnd, bottomRects, bottomRectsEnd, tmpRect);

      // copy the merged rects back into the destination
      topRectsEnd = CopyRow(destRect, tmpRect, rect);
      topRects = destRect;
      bottomRects = bottomRectsEnd;
      destRect = topRects;
    } else {
      // copy the unmerged rects
      destRect = CopyRow(destRect, topRects, topRectsEnd);

      topRects = bottomRects;
      topRectsEnd = bottomRectsEnd;
      bottomRects = bottomRectsEnd;
      if (bottomRectsEnd == end) {
        // copy the last row when we are done
        topRectsEnd = CopyRow(destRect, topRects, topRectsEnd);
      }
    }
  } while (bottomRectsEnd != end);


  uint32_t reducedCount = topRectsEnd - pixman_region32_rectangles(&this->mImpl, &n);
  // pixman has a special representation for
  // regions of 1 rectangle. So just use the
  // bounds in that case
  if (reducedCount > 1) {
    // reach into pixman and lower the number
    // of rects stored in data.
    this->mImpl.data->numRects = reducedCount;
  } else {
    *this = GetBounds();
  }
}
Exemplo n.º 5
0
void FSlateTextureAtlas::CopyDataIntoSlot( const FAtlasedTextureSlot* SlotToCopyTo, const TArray<uint8>& Data )
{
	// Copy pixel data to the texture
	uint8* Start = &AtlasData[SlotToCopyTo->Y*AtlasWidth*BytesPerPixel + SlotToCopyTo->X*BytesPerPixel];
	
	// Account for same padding on each sides
	const uint32 Padding = GetPaddingAmount();
	const uint32 AllPadding = Padding*2;

	// Make sure the actual slot is not zero-area (otherwise padding could corrupt other images in the atlas)
	check(SlotToCopyTo->Width > AllPadding);
	check(SlotToCopyTo->Height > AllPadding);

	// The width of the source texture without padding (actual width)
	const uint32 SourceWidth = SlotToCopyTo->Width - AllPadding; 
	const uint32 SourceHeight = SlotToCopyTo->Height - AllPadding;

	FCopyRowData CopyRowData;
	CopyRowData.DestData = Start;
	CopyRowData.SrcData = Data.GetData();
	CopyRowData.DestTextureWidth = AtlasWidth;
	CopyRowData.SrcTextureWidth = SourceWidth;
	CopyRowData.RowWidth = SlotToCopyTo->Width;

	// Apply the padding for bilinear filtering. 
	// Not used if no padding (assumes sampling outside boundaries of the sub texture is not possible)
	if (Padding > 0)
	{
		// Copy first color row into padding.  
		CopyRowData.SrcRow = 0;
		CopyRowData.DestRow = 0;

		if (PaddingStyle == ESlateTextureAtlasPaddingStyle::DilateBorder)
		{
			CopyRow(CopyRowData);
		}
		else
		{
			ZeroRow(CopyRowData);
		}
	}

	// Copy each row of the texture
	for (uint32 Row = Padding; Row < SlotToCopyTo->Height-Padding; ++Row)
	{
		CopyRowData.SrcRow = Row-Padding;
		CopyRowData.DestRow = Row;

		CopyRow(CopyRowData);
	}

	if (Padding > 0)
	{
		// Copy last color row into padding row for bilinear filtering
		CopyRowData.SrcRow = SourceHeight - 1;
		CopyRowData.DestRow = SlotToCopyTo->Height - Padding;

		if (PaddingStyle == ESlateTextureAtlasPaddingStyle::DilateBorder)
		{
			CopyRow(CopyRowData);
		}
		else
		{
			ZeroRow(CopyRowData);
		}
	}
}