API reference

class diag_operation : public primitive_component_base, public std::enable_shared_from_this<diag_operation>
#include <diag_operation.hpp>

Public Functions

diag_operation()
diag_operation(primitive_arguments_type &&operands, std::string const &name, std::string const &codename)

Diag Operation Primitive.

Constructs a diagonal matrix if the input is a vector, extracts the diagonal if the input is a matrix and returns unchanged input if the input is a scalar.

If used inside PhySL:

 diag (input, k=0 )

     input : Scalar, Vector or a Matrix
     k     : Which diagonal to extract or create, default being 0
Parameters
  • operands: Vector of phylanx node data objects of size either one or two

  • name: The name of the primitive

  • codename: The codename of the primitive

This primitives replicates the functionality of numpy.diag

Public Static Attributes

const match_pattern_type match_data

Protected Functions

hpx::future<primitive_argument_type> eval(primitive_arguments_type const &operands, primitive_arguments_type const &args, eval_context ctx) const

Private Functions

template<typename T>
primitive_argument_type diag1d(ir::node_data<T> &&args, std::int64_t k) const
template<typename T>
primitive_argument_type diag2d(ir::node_data<T> &&args, std::int64_t k) const
primitive_argument_type diag1d(primitive_argument_type &&args, std::int64_t k) const
primitive_argument_type diag2d(primitive_argument_type &&args, std::int64_t k) const
class gradient_operation : public primitive_component_base, public std::enable_shared_from_this<gradient_operation>
#include <gradient_operation.hpp>

Public Functions

gradient_operation()
gradient_operation(primitive_arguments_type &&operands, std::string const &name, std::string const &codename)

Gradient Operation Primitive.

Returns gradient of the input

If used inside PhySL:

 gradient (input , axis)

     input : Vector or a Matrix
     axis  : Axis to perform gradient along (optional)
Parameters
  • operands: phylanx node data objects

  • name: The name of the primitive

  • codename: The codename of the primitive

Public Static Attributes

const match_pattern_type match_data

Protected Functions

hpx::future<primitive_argument_type> eval(primitive_arguments_type const &operands, primitive_arguments_type const &args, eval_context ctx) const

Private Functions

primitive_argument_type gradient0d(primitive_arguments_type &&ops) const
primitive_argument_type gradient1d(primitive_arguments_type &&ops) const
primitive_argument_type gradient2d(primitive_arguments_type &&ops) const
template<typename T>
primitive_argument_type gradient1d(ir::node_data<T> &&arg) const
template<typename T>
primitive_argument_type gradient2d(ir::node_data<T> &&arg, std::int64_t axis) const
class linearmatrix : public primitive_component_base, public std::enable_shared_from_this<linearmatrix>
#include <linearmatrix.hpp>

Public Functions

linearmatrix()
linearmatrix(primitive_arguments_type &&args, std::string const &name, std::string const &codename)

Public Static Attributes

const match_pattern_type match_data

Protected Functions

hpx::future<primitive_argument_type> eval(primitive_arguments_type const &operands, primitive_arguments_type const &args, eval_context ctx) const

Private Functions

primitive_argument_type linmatrix(std::int64_t nx, std::int64_t ny, primitive_argument_type &&x0, primitive_argument_type &&dx, primitive_argument_type &&dy) const
template<typename T>
primitive_argument_type linmatrix(std::int64_t nx, std::int64_t ny, T x0, T dx, T dy) const

Private Members

node_data_type dtype_
class linspace : public primitive_component_base, public std::enable_shared_from_this<linspace>
#include <linspace.hpp>

Creates a linear space of evenly spaced numbers over the given interval.

Parameters
  • args: Is a vector with exactly three elements (in order): start: the first value of the sequence. stop: the last value of the sequence. It will be ignored if the number of samples is less than 2. num_samples: number of samples in the sequence.

Public Functions

linspace()

Default constructor.

linspace(primitive_arguments_type &&args, std::string const &name, std::string const &codename)

Creates a linear space of evenly spaced numbers over the given interval.

start: the first value of the sequence.

stop: the last value of the sequence. It will be ignored if the number of samples is less than 2.

num_samples: number of samples in the sequence.

Parameters
  • args: Is a vector with exactly three elements (in order):

Parameters
  • name: The name of the primitive

  • codename: The codename of the primitive

Public Static Attributes

const match_pattern_type match_data

Protected Functions

hpx::future<primitive_argument_type> eval(primitive_arguments_type const &operands, primitive_arguments_type const &args, eval_context ctx) const

Private Functions

primitive_argument_type linspace1d(primitive_argument_type &&start, primitive_argument_type &&end, std::int64_t nelements) const
template<typename T>
primitive_argument_type linspace1d(T start, T end, std::int64_t nelements) const

Private Members

node_data_type dtype_
class random : public primitive_component_base, public std::enable_shared_from_this<random>
#include <random.hpp>

Public Types

enum operation

Values:

random
random_sample
random_integers
randn

Public Functions

random()
random(primitive_arguments_type &&operands, std::string const &name, std::string const &codename)

Create a new random data element of the requested dimensions that is filled using random numbers distributed based on the given arguments

dimensions: Specifies the number of dimensions of the newly created data element

This value can either be another data element, in which case the newly created element will have the same dimensions. This can also be a list of values to use as the dimensions for the newly created data element.

parameters: (optional) Specifies what distribution to use to generate the random numbers. This has to be a list of parameters where the first list element is the name of the distribution to use (see below). The remaining list elements are specific to the distribution selected. (default:

list("normal", 0.0, 1.0)).
Note

Possible values for parameters\n list(“uniform_int”, min, max): Produces integer values evenly distributed across a range ([min, max): range of generated values)

list(“uniform”, min, max): Produces floating point values evenly distributed across a range ([min, max): range of generated values)

list(“bernoulli”, p): Produces random boolean values, according to the discrete probability function (p: probability of a trial generating true)

list(“binomial”, t, p): Produces random non-negative integer values, distributed according to the discrete binomial probability function (t: number of trials, p: probability of a trial generating true)

list(“negative_binomial”, k, p): Produces random non- negative integer values, distributed according to the discrete negative binomial probability (k: number of trial failures, p: probability of a trial generating true)

list(“geometric”, p): Produces random non-negative integer values, distributed according to the discrete geometric probability function (p: probability of a trial generating true)

list(“poisson”, mean): Produces random non-negative integer values, distributed according to discrete Poisson probability function (mean: the mean of the distribution)

list(“exponential”, lambda): Produces random non-negative floating-point values, distributed according to the exponential probability density function (lambda: the rate parameter)

list(“gamma”, alpha, beta): Produces random positive floating-point values, distributed according to the gamma probability density function (alpha: shape, beta: scale)

list(“weibull”, a, b): Produces random positive floating-point values, distributed according to the Weibull probability density function (a: shape, b: scale)

list(“extreme_value”, a, b): Produces random positive floating-point values, distributed according to the extreme value probability density function, also known as Gumbel Type I, log-Weibull, or Fisher-Tippett Type I distribution (a: location, b: scale)

list(“normal”, mean, stddev): Generates random numbers according to the Normal (or Gaussian) random number distribution (mean: mean, stddev: standard deviation)

list(“truncated_normal”, mean, stddev): Generates random numbers according to the Normal (or Gaussian) random number distribution. Values whose magnitude is more than two standard deviations from the mean are dropped and re-picked (mean: mean, stddev: standard deviation)

list(“lognormal”, m, s): Produces random numbers according to a log-normal distribution (m: log-scale, s: shape)

list(“chi_squared”, n): Produces random positive floating-point values, distributed according to the Chi-squared probability density function (n: degrees of freedom)

list(“cauchy”, a, b): Produces random positive floating-point values, distributed according to the Cauchy (Lorentz) probability density function (a: location, s: scale)

list(“fisher_f”, m, n): Produces random positive floating-point values, distributed according to the f-probability density function (m: degrees of freedom, n: degrees of freedom)

list(“student_t”, n): Produces random positive floating-point values, distributed according to the student probability density function (n: degrees of freedom)

Parameters
  • operands: Is a vector with at least one element (in order):

Parameters
  • name: The name of the primitive

  • codename: The codename of the primitive

Public Static Attributes

const std::vector<match_pattern_type> match_data

Protected Functions

hpx::future<primitive_argument_type> eval(primitive_arguments_type const &operands, primitive_arguments_type const &args, eval_context ctx) const
hpx::future<primitive_argument_type> eval_random_integers(primitive_arguments_type const &operands, primitive_arguments_type const &args, eval_context ctx) const
hpx::future<primitive_argument_type> eval_randn(primitive_arguments_type const &operands, primitive_arguments_type const &args, eval_context ctx) const
primitive_argument_type random0d(distribution_parameters_type &&params, node_data_type, eval_context ctx) const
primitive_argument_type random1d(std::size_t dim, distribution_parameters_type &&params, node_data_type, eval_context ctx) const
primitive_argument_type random2d(std::array<std::size_t, PHYLANX_MAX_DIMENSIONS> const &dims, distribution_parameters_type &&params, node_data_type, eval_context ctx) const
primitive_argument_type random3d(std::array<std::size_t, PHYLANX_MAX_DIMENSIONS> const &dims, distribution_parameters_type &&params, node_data_type, eval_context ctx) const
primitive_argument_type random4d(std::array<std::size_t, PHYLANX_MAX_DIMENSIONS> const &dims, distribution_parameters_type &&params, node_data_type, eval_context ctx) const

Private Members

operation random_operation_
class slicing_operation : public primitive_component_base, public std::enable_shared_from_this<slicing_operation>
#include <slicing_operation.hpp>

Public Types

enum slice_mode

Values:

local_mode
dist_mode

Public Functions

slicing_operation()
slicing_operation(primitive_arguments_type &&operands, std::string const &name, std::string const &codename)

Slicing Primitive.

This primitive returns a slice of the original data.

If used inside PhySL:

 slice (input,
      list(row_start, row_stop, row_steps),
      list(col_start, col_stop, col_steps)
 )

 input: Scalar, Vector, Matrix, or a list
     row_start     : Starting index of the slice (row)
     row_stop      : Stopping index of the slice (row)
     row_steps     : Go from row_start to row_stop in row_steps
     col_start     : Starting index of the slice (column)
     col_stop      : Stopping index of the slice (column)
     col_steps     : Go from col_start to col_stop in steps

Quirks: In case the input is a vector, row_start, row_stop and row_steps determine the result. col_start, col_stop and col_step are ignored internally.

Note: Indices and steps can have negative values and negative values indicate direction, similar to python.

Public Static Attributes

const std::vector<match_pattern_type> match_data

Protected Functions

hpx::future<primitive_argument_type> eval(primitive_arguments_type const &operands, primitive_arguments_type const &args, eval_context ctx) const

Private Members

bool slice_rows_
bool slice_columns_
bool slice_rows_d_
bool slice_columns_d_
bool slice_pages_
bool is_tuple_slice_
slice_mode mode_
namespace phylanx
namespace execution_tree
namespace primitives

Typedefs

using distribution_parameters_type = std::tuple<std::string, int, double, double>

Functions

primitive create_diag_operation(hpx::id_type const &locality, primitive_arguments_type &&operands, std::string const &name = "", std::string const &codename = "")
primitive create_gradient_operation(hpx::id_type const &locality, primitive_arguments_type &&operands, std::string const &name = "", std::string const &codename = "")
primitive create_linearmatrix(hpx::id_type const &locality, primitive_arguments_type &&operands, std::string const &name = "", std::string const &codename = "")
primitive create_linspace(hpx::id_type const &locality, primitive_arguments_type &&operands, std::string const &name = "", std::string const &codename = "")
primitive create_slicing_operation(hpx::id_type const &locality, primitive_arguments_type &&operands, std::string const &name = "", std::string const &codename = "")
primitive create_random(hpx::id_type const &locality, primitive_arguments_type &&operands, std::string const &name = "", std::string const &codename = "")

Variables

const match_pattern_type get_seed_match_data
const match_pattern_type set_seed_match_data
file diag_operation.hpp
#include <phylanx/config.hpp>#include <hpx/config.hpp>#include <phylanx/config/defines.hpp>#include <phylanx/config/export_definitions.hpp>#include <phylanx/config/format.hpp>#include <hpx/config/version.hpp>#include <phylanx/config/version.hpp>#include <hpx/preprocessor/cat.hpp>#include <hpx/preprocessor/expand.hpp>#include <boost/version.hpp>#include <phylanx/execution_tree/primitives/base_primitive.hpp>#include <phylanx/ast/node.hpp>#include <phylanx/ast/parser/extended_variant.hpp>#include <phylanx/util/variant.hpp>#include <phylanx/util/detail/variant.hpp>#include <cstddef>#include <exception>#include <functional>#include <initializer_list>#include <new>#include <type_traits>#include <utility>#include <memory>#include <boost/mpl/vector.hpp>#include <phylanx/ir/node_data.hpp>#include <hpx/include/util.hpp>#include <hpx/serialization/serialization_fwd.hpp>#include <hpx/errors/throw_exception.hpp>#include <array>#include <cstdint>#include <iosfwd>#include <vector>#include <blaze/Math.h>#include <blaze_tensor/Math.h>#include <phylanx/util/serialization/variant.hpp>#include <hpx/serialization/serialize.hpp>#include <boost/spirit/include/support_extended_variant.hpp>#include <boost/spirit/include/support_attributes.hpp>#include <string>#include <phylanx/execution_tree/compiler/primitive_name.hpp>#include <hpx/modules/naming.hpp>#include <hpx/runtime_local/get_locality_id.hpp>#include <phylanx/execution_tree/primitives/primitive_argument_type.hpp>#include <phylanx/ir/dictionary.hpp>#include <hpx/serialization/unordered_map.hpp>#include <unordered_map>#include <hpx/config/warnings_prefix.hpp>#include <hpx/config/warnings_suffix.hpp>#include <phylanx/ir/ranges.hpp>#include <hpx/allocator_support/internal_allocator.hpp>#include <phylanx/util/hashed_string.hpp>#include <hpx/hashing/jenkins_hash.hpp>#include <hpx/assert.hpp>#include <hpx/include/lcos.hpp>#include <hpx/include/runtime.hpp>#include <boost/utility/string_ref.hpp>#include <map>#include <set>#include <phylanx/util/generate_error_message.hpp>#include <phylanx/execution_tree/primitives/primitive_component_base.hpp>#include <hpx/async_base/launch_policy.hpp>#include <hpx/futures/future.hpp>
file gradient_operation.hpp
#include <phylanx/config.hpp>#include <phylanx/ast/node.hpp>#include <phylanx/execution_tree/primitives/base_primitive.hpp>#include <phylanx/execution_tree/primitives/primitive_component_base.hpp>#include <hpx/futures/future.hpp>#include <cstdint>#include <memory>#include <string>#include <utility>#include <vector>
file linearmatrix.hpp
#include <phylanx/config.hpp>#include <phylanx/execution_tree/primitives/base_primitive.hpp>#include <phylanx/execution_tree/primitives/node_data_helpers.hpp>#include <phylanx/execution_tree/primitives/primitive_argument_type.hpp>#include <phylanx/ir/node_data.hpp>#include <hpx/errors/throw_exception.hpp>#include <algorithm>#include <array>#include <cstddef>#include <cstdint>#include <string>#include <utility>#include <type_traits>#include <vector>#include <phylanx/execution_tree/primitives/primitive_component_base.hpp>#include <hpx/futures/future.hpp>#include <memory>
file linspace.hpp
#include <phylanx/config.hpp>#include <phylanx/execution_tree/primitives/base_primitive.hpp>#include <phylanx/execution_tree/primitives/node_data_helpers.hpp>#include <phylanx/execution_tree/primitives/primitive_component_base.hpp>#include <phylanx/ir/node_data.hpp>#include <hpx/futures/future.hpp>#include <cstdint>#include <memory>#include <string>#include <utility>#include <vector>
file random.hpp
#include <phylanx/config.hpp>#include <phylanx/execution_tree/primitives/base_primitive.hpp>#include <phylanx/execution_tree/primitives/node_data_helpers.hpp>#include <phylanx/execution_tree/primitives/primitive_component_base.hpp>#include <phylanx/util/random.hpp>#include <cstdint>#include <random>#include <hpx/futures/future.hpp>#include <array>#include <cstddef>#include <memory>#include <string>#include <tuple>#include <utility>#include <vector>#include <blaze/Math.h>
file slicing_operation.hpp
#include <phylanx/config.hpp>#include <phylanx/execution_tree/primitives/base_primitive.hpp>#include <phylanx/execution_tree/primitives/primitive_component_base.hpp>#include <phylanx/ir/node_data.hpp>#include <phylanx/util/small_vector.hpp>#include <vector>#include <hpx/futures/future.hpp>#include <array>#include <cstddef>#include <cstdint>#include <memory>#include <string>#include <utility>
dir /phylanx/src/phylanx/plugins/matrixops
dir /phylanx/src/phylanx
dir /phylanx/src/phylanx/plugins
dir /phylanx/src