Skip to content

Commit

Permalink
Fixing Alxey's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
eldakms committed Feb 19, 2016
1 parent 760fff9 commit fefd001
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 29 deletions.
8 changes: 2 additions & 6 deletions Source/Readers/ImageReader/ImageDataDeserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
#include "ImageDataDeserializer.h"
#include "ImageConfigHelper.h"

#ifndef UNREFERENCED_PARAMETER
#define UNREFERENCED_PARAMETER(P) (P)
#endif

namespace Microsoft { namespace MSR { namespace CNTK {

class ImageDataDeserializer::LabelGenerator
Expand Down Expand Up @@ -66,7 +62,7 @@ class ImageDataDeserializer::ImageChunk : public Chunk, public std::enable_share
virtual std::vector<SequenceDataPtr> GetSequence(const size_t& sequenceId) override
{
assert(sequenceId == m_description.m_id);
UNREFERENCED_PARAMETER(sequenceId);
UNUSED(sequenceId);
const auto& imageSequence = m_description;

auto image = std::make_shared<DeserializedImage>();
Expand Down Expand Up @@ -140,7 +136,7 @@ ImageDataDeserializer::ImageDataDeserializer(const ConfigParameters& config)

void ImageDataDeserializer::CreateSequenceDescriptions(std::string mapPath, size_t labelDimension)
{
UNREFERENCED_PARAMETER(labelDimension);
UNUSED(labelDimension);

std::ifstream mapFile(mapPath);
if (!mapFile)
Expand Down
6 changes: 3 additions & 3 deletions Source/Readers/ImageReader/ImageTransformers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ImageTransformerBase::Apply(SequenceDataPtr sequence,
const StreamDescription & /*outputStream*/)
{
assert(inputStream.m_storageType == StorageType::dense);
auto inputSequence = reinterpret_cast<const DenseSequenceData&>(*sequence.get());
auto inputSequence = static_cast<const DenseSequenceData&>(*sequence.get());
ImageDimensions dimensions(*inputSequence.m_sampleLayout, HWC);
int columns = static_cast<int>(dimensions.m_width);
int rows = static_cast<int>(dimensions.m_height);
Expand Down Expand Up @@ -398,7 +398,7 @@ void TransposeTransformer::Initialize(TransformerPtr next,

ImageDimensions dimensions(*stream->m_sampleLayout, HWC);

// Changing layout from NWH to NHW
// Changing from NHWC to NCHW
auto changedStream = std::make_shared<StreamDescription>(*stream);
changedStream->m_sampleLayout = std::make_shared<TensorShape>(dimensions.AsTensorShape(CHW));
m_outputStreams[id] = changedStream;
Expand Down Expand Up @@ -438,7 +438,7 @@ TransposeTransformer::TypedApply(SequenceDataPtr sequence,
const StreamDescription &outputStream)
{
assert(inputStream.m_storageType == StorageType::dense);
auto inputSequence = reinterpret_cast<DenseSequenceData&>(*sequence.get());
auto inputSequence = static_cast<DenseSequenceData&>(*sequence.get());
assert(inputSequence.m_numberOfSamples == 1);
assert(inputStream.m_sampleLayout->GetNumElements() ==
outputStream.m_sampleLayout->GetNumElements());
Expand Down
10 changes: 3 additions & 7 deletions Source/Readers/ReaderLib/BlockRandomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
#include "DataReader.h"
#include <random>

#ifndef UNREFERENCED_PARAMETER
#define UNREFERENCED_PARAMETER(P) (P)
#endif

namespace Microsoft { namespace MSR { namespace CNTK {

static inline size_t rand(const size_t begin, const size_t end)
Expand Down Expand Up @@ -290,8 +286,8 @@ BlockRandomizer::BlockRandomizer(int verbosity, size_t randomizationRangeInSampl
void BlockRandomizer::Initialize(TransformerPtr next, const ConfigParameters& readerConfig)
{
// Not used for the block randomizer.
UNREFERENCED_PARAMETER(next);
UNREFERENCED_PARAMETER(readerConfig);
UNUSED(next);
UNUSED(readerConfig);
}

void BlockRandomizer::StartEpoch(const EpochConfiguration& config)
Expand Down Expand Up @@ -394,7 +390,7 @@ Sequences BlockRandomizer::GetNextSequences(size_t sampleCount)
result.m_data.resize(sequenceDescriptions.size());

// TODO: Should prefetching be done on a single thread?
#pragma omp parallel for ordered schedule(static)
#pragma omp parallel for ordered schedule(dynamic)
for (int i = 0; i < sequenceDescriptions.size(); ++i)
{
ChunkPtr chunk = m_deserializer->GetChunk(sequenceDescriptions[i]->m_chunkId);
Expand Down
17 changes: 7 additions & 10 deletions Source/Readers/ReaderLib/DataDeserializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class Chunk
public:
// Gets sequences by id.
virtual std::vector<SequenceDataPtr> GetSequence(const size_t& sequenceId) = 0;
virtual ~Chunk() {};
virtual ~Chunk() = default;

protected:
Chunk() {}

private:
Chunk(const Chunk&) = delete;
Chunk(Chunk&&) = delete;
Chunk& operator=(const Chunk&) = delete;

protected:
Chunk() {}
};
typedef std::shared_ptr<Chunk> ChunkPtr;

Expand All @@ -50,10 +50,7 @@ typedef std::vector<const SequenceDescription*> SequenceDescriptions;
struct SequenceDataBase
{
SequenceDataBase() : m_data(nullptr) { }
virtual ~SequenceDataBase()
{

}
virtual ~SequenceDataBase() = default;

ChunkPtr m_chunk;
// A non-owned pointer. The actual size is provided for particular sequences,
Expand Down Expand Up @@ -106,7 +103,7 @@ class IDataDeserializer
// Gets a chunk.
virtual ChunkPtr GetChunk(size_t chunkId) = 0;

virtual ~IDataDeserializer() {};
virtual ~IDataDeserializer() = default;
};

typedef std::shared_ptr<IDataDeserializer> IDataDeserializerPtr;
Expand Down
2 changes: 1 addition & 1 deletion Source/Readers/ReaderLib/NoRandomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Sequences NoRandomizer::GetNextSequences(size_t sampleCount)
// TODO: Not clear whether batching will make sense for this.
// We have to re-assemble the exposed result from sequences from different chunks.
result.m_data.resize(sequences.size());
#pragma omp parallel for ordered schedule(static)
#pragma omp parallel for ordered schedule(dynamic)
for (int i = 0; i < sequences.size(); ++i)
{
result.m_data[i] = m_chunks[sequences[i]->m_chunkId]->GetSequence(sequences[i]->m_id);
Expand Down
12 changes: 10 additions & 2 deletions Source/Readers/ReaderLib/ReaderLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,26 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup>

<ClCompile>

<OpenMPSupport>true</OpenMPSupport>

</ClCompile>

</ItemDefinitionGroup>

<ItemDefinitionGroup Condition="$(DebugBuild)">
<ClCompile>
<Optimization>Disabled</Optimization>
<OpenMPSupport Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</OpenMPSupport>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="$(ReleaseBuild)">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<OpenMPSupport Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</OpenMPSupport>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand Down

0 comments on commit fefd001

Please sign in to comment.