1 #include "caffe2/operators/partition_ops.h" 6 REGISTER_CPU_OPERATOR(Partition, PartitionOp);
7 REGISTER_CPU_OPERATOR(LengthsPartition, LengthsPartitionOp);
8 REGISTER_CPU_OPERATOR(GatherByKey, GatherByKeyOp);
10 OPERATOR_SCHEMA(GatherByKey)
11 .NumInputs(2, INT_MAX)
14 Inverse operation of Partition. 16 Takes the original, full 'keys' tensor followed by sharded value tensors, 17 and returns the full value tensor, combined using the same hash used in 23 "The first input is the full keys tensor" 24 " (same as the first input of Partition).")
28 "Subsequented inputs are sharded values tensors.")
29 .Output(0,
"values",
"Reconstructed values tensor.");
31 OPERATOR_SCHEMA(Partition)
32 .NumInputsOutputs([](
int in,
int out) {
33 return in > 0 && out > 0 && out % in == 0;
36 Splits the input int tensor into multiple ones according to the first tensor. 38 Takes the first input and partitions it to shards according to the remainder of 39 values modulo the number of partitions. It requires that the first tensor is of 40 integral type. The number of partitions is derived as (num_output / num_input). 42 If additional inputs are present they must have the same shape as the first 43 input, optionally with extra trailing dimensions. They will be partitioned 44 accordingly to the first input. 46 Optional arg 'pack_first_input' transforms the first tensor values as 47 X_ij / num_partitions. 49 Outputs are ordered as 50 X_0_part_0, X_1_part_0, ..., X_N-1_part_0, X_0_part_1, ..., X_N-1_part_K-1 54 "(int, default 0) If set, the operator transforms " 55 "the first tensor values as floor(X_ij / num_partitions)")
59 "Input tensor containing data to be partitioned. The " 60 "number of input tensors might be greater than 1 but must have the " 61 "same shape as the previous tensors.")
65 "Output Partitions. The number of output tensors has to be a " 66 "multiple of the number of input tensors.");
68 OPERATOR_SCHEMA(LengthsPartition)
69 .NumInputsOutputs([](
int in,
int out) {
70 return in >= 2 && out > 0 && out % in == 0;
73 LengthsPartition splits the input int tensor into multiple ones according to the 74 second tensor. The first dimension is expected to be the tensor that describes 75 lengths of the elements. 77 Takes the second input and partitions it to shards according to the remainder of 78 values modulo the number of partitions. It requires the second tensor to be 79 a 1D-tensor of the integral type. The first tensor should be 1D-tensor of int32 80 that would represent the lengths of the elements in the input. The number of 81 partitions is derived as (num_output / num_input). 83 If additional inputs are present they must have the same shape as the first 84 input, optionally with extra trailing dimensions. They will be partitioned 85 accordingly to the first input. 87 Optional arg 'pack_first_input' transforms the first tensor values as 88 X_ij / num_partitions. 90 Outputs are ordered as 91 X_0_part_0, X_1_part_0, ..., X_N-1_part_0, X_0_part_1, ..., X_N-1_part_K-1 95 "(int, default 0) If set, the operator transforms " 96 "the first tensor values as floor(X_ij / num_partitions)")
100 "Input tensor containing data to be partitioned. The " 101 "number of input tensors might be greater than 1 but must have the " 102 "same shape as the previous tensors.")
106 "Output Partitions. The number of output tensors has to be a " 107 "multiple of the number of input tensors.");
112 NO_GRADIENT(Partition);
113 NO_GRADIENT(LengthsPartition);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...