Skip to content

Commit

Permalink
Support two simple op: tanh and floor
Browse files Browse the repository at this point in the history
  • Loading branch information
daquexian committed Aug 6, 2019
1 parent 77fa973 commit b5dd437
Show file tree
Hide file tree
Showing 7 changed files with 399 additions and 148 deletions.
14 changes: 13 additions & 1 deletion common/daq.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enum DataType:byte { Float32 = 0, Int8, Int32, Float16, Bool8,
enum FuseCode:byte { None = 0, Relu, Relu1, Relu6 }
enum LayerType:byte { Conv2D = 0, AvePool, MaxPool, Relu, Softmax, FC, Add, Concat,
DepthwiseConv2D, BatchToSpace, SpaceToBatch, StridedSlice, Mul, AddScalar, MulScalar,
Dequantize, LRN}
Dequantize, LRN, Tanh, Floor}

table Tensor {
data_type:DataType;
Expand Down Expand Up @@ -164,6 +164,16 @@ table LRN {
output:string;
}

table Tanh {
input:string;
output:string;
}

table Floor {
input:string;
output:string;
}

table Layer {
type:LayerType;
conv2d_param:Conv2D;
Expand All @@ -183,6 +193,8 @@ table Layer {
mul_scalar_param:MulScalar;
dequantize_param:Dequantize;
lrn_param:LRN;
tanh_param:Tanh;
floor_param:Floor;
}

table Model {
Expand Down
34 changes: 34 additions & 0 deletions dnnlibrary/ModelBuilderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,40 @@ ModelBuilder::Index ModelBuilder::AddLRN(const std::string &input,
return output_idx;
}
#endif // __ANDROID_API__ >= 27
#if __ANDROID_API__ >= 27
ModelBuilder::Index ModelBuilder::AddTanh(const std::string &input,
const std::string &output) {
IndexSeq input_indexes;
imm_blob_inputs_.insert(input);
const auto input_idx = operand_indexes_.at(input);
input_indexes.push_back(input_idx);
shaper_.Identity(input, output);
const OperandType operand_type =
GetOperandType(operand_types_.at(input).type, shaper_[output]);
const auto output_idx =
AddOperation(ANEURALNETWORKS_TANH, input_indexes, operand_type)[0];
RegisterOperand(output, output_idx, operand_type);
imm_blob_outputs_.insert(output);
return output_idx;
}
#endif // __ANDROID_API__ >= 27
#if __ANDROID_API__ >= 27
ModelBuilder::Index ModelBuilder::AddFloor(const std::string &input,
const std::string &output) {
IndexSeq input_indexes;
imm_blob_inputs_.insert(input);
const auto input_idx = operand_indexes_.at(input);
input_indexes.push_back(input_idx);
shaper_.Identity(input, output);
const OperandType operand_type =
GetOperandType(operand_types_.at(input).type, shaper_[output]);
const auto output_idx =
AddOperation(ANEURALNETWORKS_FLOOR, input_indexes, operand_type)[0];
RegisterOperand(output, output_idx, operand_type);
imm_blob_outputs_.insert(output);
return output_idx;
}
#endif // __ANDROID_API__ >= 27
// ModelBuilder auto generated methods end

// Methods for backward compatibility
Expand Down
Loading

0 comments on commit b5dd437

Please sign in to comment.