tensorflow/compiler/aot/codegen.cc
// Generate methods for args (inputs).
Generate methods for args (inputs).
Generate methods for args ( inputs ) .
Status GenArgMethods(const tf2xla::Config& config,
                     const xla::ProgramShapeProto& ps,
                     const CompileResult& compile_result, string* methods) {
  const int num_args = ps.parameters_size();
  if (config.feed_size() + config.variable_size() < num_args) {
    return errors::InvalidArgument(
        "mismatch between feed_size(", config.feed_size(), ")+variable_size(",
        config.variable_size(), ") and num_args(", num_args, ")");
  }
  for (int i = 0; i < config.feed_size(); ++i) {
    std::vector<std::pair<string, string>> rewrites;
    TF_RETURN_IF_ERROR(
        AddRewritesForShape(i, xla::Shape(ps.parameters(i)), &rewrites));
    const string code = R"(
  void set_arg{{NAME}}_data(const void* data) {
    set_arg_data({{I}}, data);
  }
  {{TYPE}}* arg{{NAME}}_data() {
    return static_cast<{{TYPE}}*>(arg_data({{I}}));
  }
  {{TYPE}}& arg{{NAME}}({{DIM_VARS}}) {
    return (*static_cast<{{TYPE}}(*){{DIM_SIZES}}>(
        arg_data({{I}}))){{INDICES}};
  }
  const {{TYPE}}* arg{{NAME}}_data() const {
    return static_cast<const {{TYPE}}*>(arg_data({{I}}));
  }
  const {{TYPE}}& arg{{NAME}}({{DIM_VARS}}) const {
    return (*static_cast<const {{TYPE}}(*){{DIM_SIZES}}>(
        arg_data({{I}}))){{INDICES}};
  }
  int arg{{NAME}}_size() const {
    return {{COUNT}} * sizeof({{TYPE}});
  }
  int arg{{NAME}}_count() const {
    return {{COUNT}};
  }
)";
    *methods += RewriteWithName(absl::StrCat(i), code, rewrites);
    if (!config.feed(i).name().empty()) {
      *methods += RewriteWithName("_" + config.feed(i).name(), code, rewrites);
    }
  }
  return Status::OK();
}
Status GenArgMethods ( const tf2xla :: Config & config , const xla :: ProgramShapeProto & ps , const CompileResult & compile_result , string * methods ) { const int num_args = ps . parameters_size ( ) ; if ( config . feed_size ( ) + config . variable_size ( ) < num_args ) { return errors :: InvalidArgument ( " " , config . feed_size ( ) , " " , config . variable_size ( ) , " " , num_args , " " ) ; } for ( int i = 0 ; i < config . feed_size ( ) ; ++ i ) { std :: vector < std :: pair < string , string > > rewrites ; TF_RETURN_IF_ERROR ( AddRewritesForShape ( i , xla :: Shape ( ps . parameters ( i ) ) , & rewrites ) ) ; const string code = R" ( 
  void set_arg{{NAME}}_data(const void* data) {
    set_arg_data({{I}}, data);
  }
  {{TYPE}}* arg{{NAME}}_data() {
    return static_cast<{{TYPE}}*>(arg_data({{I}}));
  }
  {{TYPE}}& arg{{NAME}}({{DIM_VARS}}) {
    return (*static_cast<{{TYPE}}(*){{DIM_SIZES}}>(
        arg_data({{I}}))){{INDICES}};
  }
  const {{TYPE}}* arg{{NAME}}_data() const {
    return static_cast<const {{TYPE}}*>(arg_data({{I}}));
  }
  const {{TYPE}}& arg{{NAME}}({{DIM_VARS}}) const {
    return (*static_cast<const {{TYPE}}(*){{DIM_SIZES}}>(
        arg_data({{I}}))){{INDICES}};
  }
  int arg{{NAME}}_size() const {
    return {{COUNT}} * sizeof({{TYPE}});
  }
  int arg{{NAME}}_count() const {
    return {{COUNT}};
  }
 ) " ; * methods += RewriteWithName ( absl :: StrCat ( i ) , code , rewrites ) ; if ( ! config . feed ( i ) . name ( ) . empty ( ) ) { * methods += RewriteWithName ( " " + config . feed ( i ) . name ( ) , code , rewrites ) ; } } return Status :: OK ( ) ; }
Generate methods for args (inputs).
Generate methods for args ( inputs ) .
// feed_size() + variable_size() is the maximum number of args as an // implementation may not create an argument for an unused variable.