Skip to content

Commit

Permalink
Auto-convert to D2
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-wakeling-sociomantic committed Sep 3, 2018
1 parent a150704 commit a05543b
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions integrationtest/mxnet/MNIST.d
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private struct ImageFileHeader

public int numImages ()
{
return ntohl(this.num_images);
return ntohl((&this).num_images);
}


Expand All @@ -306,7 +306,7 @@ private struct ImageFileHeader

public int numRows ()
{
return ntohl(this.num_rows);
return ntohl((&this).num_rows);
}


Expand All @@ -320,7 +320,7 @@ private struct ImageFileHeader

public int numCols ()
{
return ntohl(this.num_cols);
return ntohl((&this).num_cols);
}
}

Expand Down Expand Up @@ -402,7 +402,7 @@ private struct LabelFileHeader

public int numLabels ()
{
return ntohl(this.num_labels);
return ntohl((&this).num_labels);
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/mxnet/Atomic.d
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private struct AtomicSymbolInfo

public cstring toString ()
{
return format("{}", *this);
return format("{}", *(&this));
}


Expand All @@ -244,10 +244,10 @@ private struct AtomicSymbolInfo
***************************************************************************/

public void toString (FormatterSink sink)
public void toString (scope FormatterSink sink)
in
{
assert(this.creator !is null);
assert((&this).creator !is null);
}
body
{
Expand All @@ -263,7 +263,7 @@ private struct AtomicSymbolInfo
Const!(char)* return_type;

invoke!(MXSymbolGetAtomicSymbolInfo)
(this.creator, &name, &description,
((&this).creator, &name, &description,
&num_args, &arg_names, &arg_type_infos, &arg_descriptions,
&key_var_num_args, &return_type);

Expand Down Expand Up @@ -329,7 +329,7 @@ private struct AtomicSymbolList

public cstring toString ()
{
return format("{}", *this);
return format("{}", *(&this));
}


Expand All @@ -345,13 +345,13 @@ private struct AtomicSymbolList
***************************************************************************/

public void toString (FormatterSink sink)
public void toString (scope FormatterSink sink)
{
foreach (creator; atomicSymbolCreatorList())
{
assert(creator !is null);

if (this.detailed_info)
if ((&this).detailed_info)
{
sformat(sink, "----\n");
sformat(sink, "{}", AtomicSymbolInfo(creator));
Expand Down
4 changes: 2 additions & 2 deletions src/mxnet/Context.d
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public struct Context

public DeviceType type ()
{
return this.type_;
return (&this).type_;
}

unittest
Expand All @@ -93,7 +93,7 @@ public struct Context

public int id ()
{
return this.id_;
return (&this).id_;
}

unittest
Expand Down
2 changes: 1 addition & 1 deletion src/mxnet/Handle.d
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public class MXNetHandle (HandleType, alias FreeHandleFunction)
***************************************************************************/

public bool exists () /* d1to2fix_inject: const */
public bool exists () const
{
return this.c_api_handle !is null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mxnet/NDArray.d
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ public alias Tuple!(float, double, int, ubyte) SupportedElementTypes;

public template isSupportedElementType (T)
{
const bool isSupportedElementType =
static immutable bool isSupportedElementType =
IndexOf!(T, SupportedElementTypes) < SupportedElementTypes.length;
}

Expand Down
6 changes: 3 additions & 3 deletions src/mxnet/Symbol.d
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ public class Activation : Symbol
}
body
{
const istring[] activations = ["relu", "sigmoid", "softrelu", "tanh"];
static immutable istring[] activations = ["relu", "sigmoid", "softrelu", "tanh"];

istring key = "act_type";

Expand Down Expand Up @@ -889,7 +889,7 @@ public class SoftmaxOutput : Symbol
}
body
{
const istring[] softmax_normalizations = ["batch", "null", "valid"];
static immutable istring[] softmax_normalizations = ["batch", "null", "valid"];

alias typeof(Config.tupleof) ConfigTuple;

Expand Down Expand Up @@ -1120,7 +1120,7 @@ public class Dot : Symbol
c_keys[1] = keys[1].ptr;

Immut!(char)*[2] c_values;
const istring[] true_and_false = ["false", "true"];
static immutable istring[] true_and_false = ["false", "true"];
c_values[0] = true_and_false[transpose_x].ptr;
c_values[1] = true_and_false[transpose_y].ptr;

Expand Down
4 changes: 2 additions & 2 deletions src/mxnet/Util.d
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ version(UnitTest)

public mstring toNoLossString (in float x, mstring buf)
{
const max_length = 1 + // optional minus sign
static immutable max_length = 1 + // optional minus sign
1 + // leading decimal digit
1 + // .
8 + // 8 decimal digits
1 + // e
1 + // sign
2; // decimal exponent
const format_string = "{:e8}";
static immutable format_string = "{:e8}";

enforce(buf.length >= max_length);
return snformat(buf, format_string, x);
Expand Down
4 changes: 2 additions & 2 deletions src/mxnet/c/c_api.d
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ int MXExecutorBindEX (SymbolHandle symbol_handle, int dev_type, int dev_id, mx_u
/*!
* \brief set a call back to notify the completion of operation
*/
int MXExecutorSetMonitorCallback (ExecutorHandle handle, ExecutorMonitorCallback callback, void* callback_handle);
int MXExecutorSetMonitorCallback (ExecutorHandle handle, scope ExecutorMonitorCallback callback, void* callback_handle);
//--------------------------------------------
// Part 5: IO Interface
//--------------------------------------------
Expand Down Expand Up @@ -1259,7 +1259,7 @@ int MXRtcPush (RtcHandle handle, mx_uint num_input, mx_uint num_output, NDArrayH
*/
int MXRtcFree (RtcHandle handle);

int MXCustomOpRegister (Const!(char)* op_type, CustomOpPropCreator creator);
int MXCustomOpRegister (Const!(char)* op_type, scope CustomOpPropCreator creator);

// __cplusplus

Expand Down

0 comments on commit a05543b

Please sign in to comment.