swh:1:snp:f50ab94432af916b5fb8b4ad831e8dddded77084
Raw File
Tip revision: 6cb945e453d8e5b19221a5ad820b8c10a4864368 authored by Tianjun Xiao on 21 October 2016, 14:38:14 UTC
Remove debug info for triplet
Tip revision: 6cb945e
SequencePacker.h
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
//

#pragma once

#include "PackerBase.h"

namespace Microsoft { namespace MSR { namespace CNTK {

// This packer generates minibatches containing full sequences packed for 
// efficient (concurrent) consumption on a GPU.
class SequencePacker : public PackerBase
{
public:
    SequencePacker(
        MemoryProviderPtr memoryProvider,
        SequenceEnumeratorPtr sequenceEnumerator,
        const std::vector<StreamDescriptionPtr>& streams) :
        PackerBase(memoryProvider, sequenceEnumerator, streams)
    {

    }

    virtual Minibatch ReadMinibatch() override;

protected:
    virtual MBLayoutPtr PackDenseStream(const StreamBatch& batch, size_t streamIndex);

    virtual MBLayoutPtr PackSparseStream(const StreamBatch& batch, size_t streamIndex);

    // Given a number of sequences, creates an MB layout that is used to guide
    // the actual packing.
    virtual MBLayoutPtr CreateMBLayout(const StreamBatch& batch);

    // Helper function to check the sample shape of input samples.
    void CheckSampleShape(const std::vector<SequenceDataPtr>& minibatch, StreamDescriptionPtr outputStream);
};

typedef std::shared_ptr<SequencePacker> SequencePackerPtr;

}}}
back to top