1 #include "caffe2/operators/elementwise_logical_ops.h" 6 REGISTER_CPU_OPERATOR(Where, WhereOp<CPUContext>);
12 .AllowInplace({{1, 2}})
13 .IdenticalTypeAndShapeOfInput(1)
15 Operator Where takes three input data (Tensor<bool>, Tensor<T>, Tensor<T>) and 16 produces one output data (Tensor<T>) where z = c ? x : y is applied elementwise. 18 .Input(0, "C",
"input tensor containing booleans")
19 .Input(1,
"X",
"input tensor")
20 .Input(2,
"Y",
"input tensor")
21 .Output(0,
"Z",
"output tensor");
23 SHOULD_NOT_DO_GRADIENT(Where);
25 REGISTER_CPU_OPERATOR(IsMemberOf, IsMemberOfOp<CPUContext>);
28 OPERATOR_SCHEMA(IsMemberOf)
31 .TensorInferenceFunction(
32 [](
const OperatorDef&,
const vector<TensorShape>& input_types) {
33 vector<TensorShape> out(1);
34 out[0] = input_types[0];
35 out[0].set_data_type(TensorProto_DataType::TensorProto_DataType_BOOL);
38 .Arg(
"value",
"Declare one value for the membership test.")
41 "The data type for the elements of the output tensor." 42 "Strictly must be one of the types from DataType enum in TensorProto.")
44 IsMemberOf takes input data (Tensor<T>) and a list of values as argument, and 45 produces one output data (Tensor<bool>) where the function `f(x) = x in values`, 46 is applied to the data tensor elementwise. 48 .Input(0, "X",
"Input tensor of any shape")
49 .Output(0,
"Y",
"Output tensor (same size as X containing booleans)");
51 SHOULD_NOT_DO_GRADIENT(IsMemberOf);
56 std::unordered_set<int32_t>& IsMemberOfValueHolder::get<int32_t>() {
61 std::unordered_set<int64_t>& IsMemberOfValueHolder::get<int64_t>() {
66 std::unordered_set<bool>& IsMemberOfValueHolder::get<bool>() {
71 std::unordered_set<string>& IsMemberOfValueHolder::get<string>() {
72 return string_values_;
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...