From 59910e0d340049ff416553754910787c69d3b895 Mon Sep 17 00:00:00 2001 From: Zhou Wang Date: Thu, 16 Mar 2017 15:10:52 +0100 Subject: [PATCH] not expose unused NDArrayViewConstructor --- Source/CNTKv2LibraryDll/API/CNTKLibrary.h | 1 - bindings/csharp/Swig/cntk_cs.i | 66 +++++++++++------------ 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/Source/CNTKv2LibraryDll/API/CNTKLibrary.h b/Source/CNTKv2LibraryDll/API/CNTKLibrary.h index e26669400..442e6349f 100644 --- a/Source/CNTKv2LibraryDll/API/CNTKLibrary.h +++ b/Source/CNTKv2LibraryDll/API/CNTKLibrary.h @@ -2158,7 +2158,6 @@ namespace CNTK return Create(sampleShape, sequences, {}, device, readOnly); } - /// /// Create a new Value object containing a collection of variable length sequences. /// diff --git a/bindings/csharp/Swig/cntk_cs.i b/bindings/csharp/Swig/cntk_cs.i index a103ae4c9..aecab9fc1 100755 --- a/bindings/csharp/Swig/cntk_cs.i +++ b/bindings/csharp/Swig/cntk_cs.i @@ -1096,7 +1096,7 @@ // Is CreateBatch for OneHot really useful? var input = new System.Collections.Generic.List>(); batch.ForEach(element => input.Add(new System.Collections.Generic.List(1) {element})); - + return Create(dimension, input, new System.Collections.Generic.List(0), device, readOnly); } @@ -1135,6 +1135,36 @@ return Create(dimension, batchOfSequences, sequenceStartFlags, device, readOnly); } + private static Value Create(uint dimension, + System.Collections.Generic.List> sequences, + System.Collections.Generic.List sequenceStartFlags, + DeviceDescriptor device, + bool readOnly = false) + { + var seqFlags = new BoolVector(sequenceStartFlags); + var inputSeqVector = new SizeTVectorVector(); + var sizeTVectorRefList = new System.Collections.Generic.List(); + foreach (var seq in sequences) + { + var s = new SizeTVector(seq); + sizeTVectorRefList.Add(s); + inputSeqVector.Add(s); + } + if (typeof(T).Equals(typeof(float))) + { + return Value.CreateOneHotFloat(dimension, inputSeqVector, seqFlags, device, readOnly); + } + else if (typeof(T).Equals(typeof(double))) + { + return Value.CreateOneHotDouble(dimension, inputSeqVector, seqFlags, device, readOnly); + } + else + { + throw new System.ArgumentException("The data type " + typeof(T).ToString() + " is not supported. Only float or double is supported by CNTK."); + } + } + + // Create Value object from sparse input public static Value CreateSequence(NDShape sampleShape, uint sequenceLength, int[] colStarts, int[] rowIndices, T[] nonZeroValues, uint numNonZeroValues, bool sequenceStartFlag, @@ -1191,35 +1221,6 @@ return Value.CreateSequence(dimension, sequenceLength, colStarts, rowIndices, nonZeroValues, numNonZeroValues, true, device, readOnly); } - private static Value Create(uint dimension, - System.Collections.Generic.List> sequences, - System.Collections.Generic.List sequenceStartFlags, - DeviceDescriptor device, - bool readOnly = false) - { - var seqFlags = new BoolVector(sequenceStartFlags); - var inputSeqVector = new SizeTVectorVector(); - var sizeTVectorRefList = new System.Collections.Generic.List(); - foreach (var seq in sequences) - { - var s = new SizeTVector(seq); - sizeTVectorRefList.Add(s); - inputSeqVector.Add(s); - } - if (typeof(T).Equals(typeof(float))) - { - return Value.CreateOneHotFloat(dimension, inputSeqVector, seqFlags, device, readOnly); - } - else if (typeof(T).Equals(typeof(double))) - { - return Value.CreateOneHotDouble(dimension, inputSeqVector, seqFlags, device, readOnly); - } - else - { - throw new System.ArgumentException("The data type " + typeof(T).ToString() + " is not supported. Only float or double is supported by CNTK."); - } - } - // Create value object from NDArrayView public static Value Create(NDShape sampleShape, System.Collections.Generic.List sequences, @@ -1320,9 +1321,6 @@ } return; } - - - %} %extend CNTK::Value { @@ -1344,7 +1342,7 @@ // %ignore CNTK::NDArrayView::NDArrayView(::CNTK::DataType dataType, const NDShape& viewShape, void* dataBuffer, size_t bufferSizeInBytes, const DeviceDescriptor& device, bool readOnly = false); %ignore CNTK::NDArrayView::NDArrayView(::CNTK::DataType dataType, const NDShape& viewShape, const void* dataBuffer, size_t bufferSizeInBytes, const DeviceDescriptor& device); - +%ignore CNTK::NDArrayView::NDArrayView(double value, DataType dataType = DataType::Float, const NDShape& viewShape = { 1 }, const DeviceDescriptor& device = DeviceDescriptor::UseDefaultDevice(), bool readOnly = false); %extend CNTK::NDArrayView { NDArrayView(const NDShape& viewShape, float *dataBuffer, size_t numBufferElements, const DeviceDescriptor& device, bool readOnly = false)