/// <summary> /// Attempts to use a typed version of the BinaryConv call, /// to avoid dependency on the JIT being able to inline struct methods /// </summary> /// <typeparam name="Ta">The type of input data to operate on</typeparam> /// <typeparam name="Tb">The type of output data to operate on</typeparam> /// <typeparam name="C">The type of operation to perform</typeparam> /// <param name="op">The operation instance</param> /// <param name="in1">The left-hand-side input argument</param> /// <param name="in2">The right-hand-side input argument</param> /// <param name="out">The output target</param> private static bool UFunc_Op_Inner_BinaryConv_LhsScalar_Flush_Typed <Ta, Tb, C>(C op, Ta scalar, NdArray <Ta> in2, NdArray <Tb> @out) { System.Reflection.MethodInfo f; var key = typeof(Ta).FullName + "#" + typeof(Tb).FullName + "#" + op.GetType().FullName + "#LHS"; if (!_resolvedMethods.TryGetValue(key, out f)) { var n = typeof(UFunc).GetMethod("UFunc_Op_Inner_BinaryConv_LhsScalar_Flush", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, null, new Type[] { op.GetType(), scalar.GetType(), in2.GetType(), @out.GetType() }, null); _resolvedMethods[key] = f = n == null ? null : n.MakeGenericMethod(new Type[] { typeof(Ta), typeof(Tb), op.GetType() }); } if (f != null) { f.Invoke(null, new object[] { op, scalar, in2, @out }); return(true); } return(false); }
/// <summary> /// Attempts to use a typed version of the NullaryImpl call, /// to avoid dependency on the JIT being able to inline struct methods /// </summary> /// <typeparam name="T">The type of data to generat</typeparam> /// <typeparam name="C">The type of operation to perform</typeparam> /// <param name="op">The operation instance</param> /// <param name="out">The output target</param> private static bool UFunc_Op_Inner_Nullary_Impl_Flush_Typed <T, C>(C op, NdArray <T> @out) where C : struct, INullaryOp <T> { System.Reflection.MethodInfo f; var key = typeof(T).FullName + "#" + op.GetType().FullName + "#NULL"; if (!_resolvedMethods.TryGetValue(key, out f)) { var n = typeof(UFunc).GetMethod("UFunc_Op_Inner_Nullary_Impl_Flush", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, null, new Type[] { op.GetType(), @out.GetType() }, null); _resolvedMethods[key] = f = n == null ? null : n.MakeGenericMethod(new Type[] { typeof(T), op.GetType() }); } if (f != null) { f.Invoke(null, new object[] { op, @out }); return(true); } return(false); }
/// <summary> /// Attempts to use a typed version of the Binary call, /// to avoid dependency on the JIT being able to inline struct methods /// </summary> /// <typeparam name="C">The type of operation to perform</typeparam> /// <param name="op">The operation instance</param> /// <param name="in1">The left-hand-side input argument</param> /// <param name="in2">The right-hand-side input argument</param> /// <param name="out">The output target</param> internal static bool UFunc_Aggregate_Entry_Typed <T, C>(C op, NdArray <T> in1, out T @out) { System.Reflection.MethodInfo f; var key = typeof(T).FullName + "#" + op.GetType().FullName + "#AGR"; if (!_resolvedMethods.TryGetValue(key, out f)) { var n = typeof(Aggregate).GetMethod("Aggregate_Entry_" + typeof(T).Name + "_TypedImpl", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, null, new Type[] { op.GetType(), in1.GetType() }, null); _resolvedMethods[key] = f = n == null ? null : n.MakeGenericMethod(new Type[] { op.GetType() }); } if (f != null) { @out = (T)f.Invoke(null, new object[] { op, in1 }); return(true); } else { @out = default(T); } return(false); }
/// <summary> /// Attempts to use a typed version of the Unary call, /// to avoid dependency on the JIT being able to inline struct methods /// </summary> /// <typeparam name="Ta">The type of input data to operate on</typeparam> /// <typeparam name="Tb">The type of output data to operate on</typeparam> /// <typeparam name="C">The type of operation to perform</typeparam> /// <param name="op">The operation instance</param> /// <param name="in1">The left-hand-side input argument</param> /// <param name="out">The output target</param> private static bool UFunc_Op_Inner_Unary_Flush_Typed <Ta, Tb, C>(C op, NdArray <Ta> in1, NdArray <Tb> @out) { System.Reflection.MethodInfo f; var key = typeof(Ta).FullName + "#" + typeof(Tb).FullName + "#" + op.GetType().FullName + "#UN"; if (!_resolvedMethods.TryGetValue(key, out f)) { var n = typeof(Apply).GetMethod("UFunc_Op_Inner_Unary_Flush_" + typeof(Ta).Name + "_TypedImpl", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, null, new Type[] { op.GetType(), in1.GetType(), @out.GetType() }, null); _resolvedMethods[key] = f = n == null ? null : n.MakeGenericMethod(new Type[] { op.GetType() }); } if (f != null) { f.Invoke(null, new object[] { op, in1, @out }); return(true); } return(false); }
/// <summary> /// Attempts to use a typed version of the Binary call, /// to avoid dependency on the JIT being able to inline struct methods /// </summary> /// <typeparam name="C">The type of operation to perform</typeparam> /// <param name="op">The operation instance</param> /// <param name="in1">The left-hand-side input argument</param> /// <param name="in2">The right-hand-side input argument</param> /// <param name="out">The output target</param> internal static bool UFunc_Reduce_Inner_Flush_Typed <T, C>(C op, long axis, NdArray <T> in1, NdArray <T> @out) { System.Reflection.MethodInfo f; var key = typeof(T).FullName + "#" + op.GetType().FullName + "#RED"; if (!_resolvedMethods.TryGetValue(key, out f)) { var n = typeof(Reduce).GetMethod("UFunc_Reduce_Inner_Flush_" + typeof(T).Name + "_TypedImpl", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, null, new Type[] { op.GetType(), axis.GetType(), in1.GetType(), @out.GetType() }, null); _resolvedMethods[key] = f = n == null ? null : n.MakeGenericMethod(new Type[] { op.GetType() }); } if (f != null) { f.Invoke(null, new object[] { op, axis, in1, @out }); return(true); } return(false); }